![](/img/trans.png)
[英]Oracle to Sql server: how to reproduce this select statement?
[英]SELECT statement in Oracle and SQL Server
我有一个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语句。 如何在Oracle中使select语句起作用?
如果要使用v_num
块中的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;
/
它应该是
Declare v_num number;
begin
--//........while loops/ if conditions...
--//........remove code for simplicity
select num from tbl where cnd = :v_num;
end;
/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.