我有一个SQL Server脚本,例如
declare @num int
begin
--//........while loops/ if conditions...
--//........remove code for simplicity
select num from tbl where cnd = @num;
end
我已经在Oracle中做到了;
Declare v_num number;
begin
--//........while loops/ if conditions...
--//........remove code for simplicity
select num from tbl where cnd = v_num;
end;
/
我收到一个错误
PLS-00428:此SELECT语句中应有一个INTO子句
整个sql服务器查询大约有500行,其中可能已声明和分配了变量...。在脚本的末尾,有一个使用其中许多变量和多个表的select语句。我怎样才能使该select语句在Oracle中工作?
如果v_num
要从贴花块中使用,则应按照以下步骤重写代码:
Declare v_num number;
begin
--//........while loops/ if conditions...
--//........remove code for simplicity
select num from tbl where cnd = v_num ;
end;
/
如果使用以下命令:
Declare v_num number;
begin
--//........while loops/ if conditions...
--//........remove code for simplicity
select num from tbl where cnd = :v_num ;
end;
/
您必须将值插入参数 v_num
如果你想选择的值num
到v_num
你应该重写你的代码如下:
Declare v_num number;
begin
--//........while loops/ if conditions...
--//........remove code for simplicity
select num into v_num from tbl;
end;
/
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句