動態條件的繫結變數的解決

rainbowbridg發表於2007-08-07

cStr = 'select * from tbl_name where a=:a1';
if aa=bb then
cStr = cStr || ' and b=:a2'
end if;
if cc<>dd then
cStr = cStr || ' and b=:a3'
end if;

dbms_sql.parse(nNum,cStr,DBMS_SQL.native);
dbms_sql.bind_variable(nNum,':a1',a1);

if aa=bb then
dbms_sql.bind_variable(nNum,':a2',a2);
end if;
if cc<>dd then
dbms_sql.bind_variable(nNum,':a3',a3);
end if;

http://www.itpub.net/showthread.php?s=&postid=8235339#post8235339

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7916042/viewspace-933348/,如需轉載,請註明出處,否則將追究法律責任。

相關文章