PB带参数带结果集的动态SQL查询

strSelectedDepartment=Trim(parent.cb_department.text)
string strSelectedDepartmentCode

//************
string strSQL
strSQL="select bmbh from pub_bm where bmmc= ?"
declare cr dynamic cursor for SQLSA;
prepare SQLSA from :strSQL;
open dynamic cr using :strSelectedDepartment;
Label:
fetch cr into :strSelectedDepartmentCode;
if SQLCA.SQLCode=0 then//如果成功取出记录
//进行相应处理
goto Label//取下一条
end if

close cr;//关闭游标
//**********

原文地址:https://www.cnblogs.com/quietwalk/p/1936273.html