common_login(1)//连接数据库(自定义函数)
String sendman
datetime applytime
string position,position2,position_ls
string str1,usertype,user1
double id1,count1
applytime = common_system_time2()
//
declare bmlx_cursor cursor for select id,sendman,usertype from TABLE81 WHERE link_id=(select id from TABLE80 where plantaskcode=:plantaskcode) and yesornofinish='0' using userdatabase;
open bmlx_cursor;
fetch bmlx_cursor into :id1,:sendman,:usertype;
DO WHILE userdatabase.sqlcode = 0
choose case usertype
case 'USER'
select count(*) into :count1 from TABLE39 where zh=:username using userdatabase;
if count1 > 0 then
str1 = str1+" id="+string(id1)+" or " //用于检索81表
end if 
case 'ORG'
if pos(sendman,'of') > 0 then
position = common_get_string(sendman,1,' of ')
position2 = common_get_string(sendman,0,' of ')
//判断当前用户的职务
select username into :user1 from TABLE37 where organizename=:position2 and position1=(select bm from TABLE13 where dytj='zw' and bmnr=:position) using userdatabase;
if user1 = username then
str1 = str1+" id="+string(id1)+" or " //用于检索81表
end if  end if 
end choose
fetch bmlx_cursor into :id1,:sendman,:usertype;
LOOP
CLOSE bmlx_cursor;
str1 = left(str1,len(str1) - 3)
common_login(0)//断开数据库