0
我是从的Transact-SQL到Oracle移植存储过程来填充输出变量,我有下面的结构必须游标循环中使用动态SQL:如何使用执行立即
open curRBL
--iterate over cursor rows of interest, and execute a query to evaluate a rule for each row.
fetch next from curRBL into varLimitNumber, varComponentRow, varComponentColumn, varFilterString
while curRBL%FOUND
begin
--count the matching current sample records
set varRBLSqlQuery = 'select count(*) into :1 from samples where samplecode= :2 and auditflag=0 and :3 ';
execute immediate varRBLSqlQuery using varResult, varSampleCode, varFilterString; <--doesn't work as I need
if varResult>0
--do something with the current cursor row...
begin
--some code goes here
end;
fetch next from curRBL into varLimitNumber, varComponentRow, varComponentColumn, varFilterString;
end; --cursor loop
我的问题是我不知道如何从动态查询中获取*()*到我的本地变量varResult(我的行5 & 6以上在这方面不起作用)。任何人都可以建议吗?
好,试过了。我得到一个编译器错误“PL/SQL:SQL语句被忽略”这个行集varRBLSqlQuery ='select count(*)from sample where samplecode =:1 and auditflag = 0 and:2'; – 2014-12-03 14:41:19
我不知道t-sql,但我想表达式'set var = value;'应改为'var:= value;' – 2014-12-03 14:47:43
啊!我现在看到了。 “Set var =”是Sql Server Tansact-SQL,我没有发现它。 – 2014-12-03 14:56:20