ลองไล่คำสั่งตามตัวอย่างนี้นะครับ
var
fan,fdepartment,fonlineid : string;
tc:tclientdataset;
begin
//showmessage('SYS_AN_Script');
tc:=tclientdataset.create(nil);
fonlineid:=get_onlineid;
fan:= GetGlobalValue('AN');
fdepartment := getsqldata('select department from onlineuser where onlineid="'+fonlineid+'"');
{======================check refer cost=======================}
if (fdepartment='ËéͪÓÃÐàÔ¹') or (fdepartment='ËéͨèÒÂÂÒ') then
begin
if getsqldata('select count(r.vn) as cc from ipt i '+
'left outer join referout r on r.vn=i.an '+
'where r.vn="'+fan+'" and r.department="IPD" ')>0 then
begin
showmessage('¼Ùé»èÇÂÃÒ¹Õéà»ç¹ case refer ¡ÃسҵÃǨÊͺ¤èÒà refer 500 ºÒ·´éǤÃѺ');
end;
end
end;