PB動態SQL語句執行應用

2021-06-08 09:06:16 字數 1418 閱讀 2565

decimal c_value

integer li_returns

datetime ldt_date

string ls_date

ldt_date = adt_date

string ls_sqlstring

//ls_sqlstring = 'select isnull('+colname+',0) from '+&

//'(select usr_id,gwgz,qjj,wpbt,zfgjj,dkdj,fzf,ghhf,zfbt  from gzlr where datediff(mm,time,?) = 0 except '+&

//'select usr_id,gwgz,qjj,wpbt,zfgjj,dkdj,fzf,ghhf,zfbt  from gzlr where datediff(mm,time,?) = 0) as a '+&

//'where a.usr_id = ?'

ls_sqlstring = 'select '+colname+' from '+&

'( select usr_id,gwgz,qjj,wpbt,zfgjj,dkdj,fzf,ghhf,zfbt  from gzlr where datediff(mm,time,?) = 1 ) as a '+&

' where a.usr_id = ?'

//'( select usr_id,gwgz,qjj,wpbt,zfgjj,dkdj,fzf,ghhf,zfbt  from gzlr where datediff(mm,time,?) = 1) as a '+&

//execute immediate :ls_sqlstring using sqlca;

declare my_cursor dynamic cursor for sqlsa;

//sqlstatament = "select emp_id from employee  where emp_state = ?"

//ls_sqlstring = "select js from ksjs where 1 = ? and 2 = ?"

//int i = 1,j = 1

prepare sqlsa from :ls_sqlstring;

open dynamic my_cursor using :usrid;

//messagebox('',ls_sqlstring)

//messagebox('',colname+'/'+ls_date+'/'+usrid)

fetch my_cursor into :c_value;

close my_cursor;

adc_lastvalue = c_value

if c_value <> colvalue then

return 1

else

return 0

end if

PB呼叫動態SQL語句

轉截自 原文解釋的比較詳細 本文只做以後用到的時候方便查詢 第一種 這種型別的動態sql語句經常用來執行ddl或者資料庫專用的其他sql語句。語法格式是 execute immediate sqlstatement 其中sqlstatement是個字串,其內容是有效的sql語句 transactio...

ORACLE 動態執行SQL語句

oracle 動態sql oracle 動態sql有兩種寫法 用 dbms sql 或 execute immediate,建議使用後者。試驗步驟如下 1.ddl 和 dml ddl begin execute immediate drop table temp 1 execute immediat...

ORACLE 動態執行SQL語句

oracle 動態sql oracle 動態sql有兩種寫法 用 dbms sql 或 execute immediate,建議使用後者。試驗步驟如下 1.ddl 和 dml sql ddl begin execute immediate drop table temp 1 execute imme...