powerbuilder中如何使用dblink跨庫中的表
在powerbuilder中使用查詢語句並返回值
1、定義變數
int ll_rtn //返回值
string ls_sql,ls_where //sql變數和where條件
2、寫dblink關聯表
ls_sql = "select count(1) from table1@dblink a" + '~r~n'+&
"inner join table2@dblink b on b.id = a.id" + '~r~n'+ &
"inner join table3@dblink c on a.in_id = c.in_id and a.id = c.id" + '~r~n'+ &
"where c.in_id = ?"
ls_where = "變數名"
declare cursor_base dynamic cursor for sqlsa;
prepare sqlsa from :ls_sql using sqlca;
open dynamic cursor_base using :ls_where;
do
fetch cursor_base into :ll_rtn;
loop while sqlca.sqlcode = 0
close cursor_base;
3、返回值
if ll_rtn >0 then
return 1
else
return 0
end if