存储过程内如何将SQL语句赋值给变量
SQL code
create or replace PROCEDURE ROUTE(
p1 in LIST,
p2 out number
) as
maxid number;
begin
maxid := 'select max(id) from LAMPCONTROLROUTE' ;
........
end;
这样的话 maxid 变成了字符串
加@
@maxid number;
select @maxid=max(id) from LAMPCONTROLROUTE ;
也报错
请问如何将SQL语句结果赋值给变量;
------解决方案--------------------select max(id) into maxid from LAMPCONTROLROUTE ;
oracle 取变量的值,into
------解决方案--------------------select 字段1,字段2... into 变量1,变量2... from table
------解决方案--------------------tsql = 'select max(id) from LAMPCONTROLROUTE ' ;
execute immediate tsql into result;
------解决方案-------------------- ......
begin
select max(id) into maxid from LAMPCONTROLROUTE;
........
end;
------解决方案--------------------select max(id) into maxid from LAMPCONTROLROUTE;
就可以了.