在Application Engine 中 调用Query

Function SG_ExecQuery() Returns boolean;
Local string &sOutFile;
Local Record &rcdQryRunParms;
Local Record &rcdQryPrompts;
Local SQL &sqlSelectQryParms;
Local number &cnt, &i, &Result;
Local ApiObject &aQry, &QryRunTimePrompts;
Local boolean &bPublic;
Local number &nOrigPSMessagesMode;
Local ApiObject &PSMessages;
Local number &MsgSetNbr, &MsgNbr;
Local boolean &bResult;


&nOrigPSMessagesMode = %Session.PSMessagesMode;
%Session.PSMessagesMode = 1;
&sQryName = "Your Query Name";
&sOutFile = %FilePath | &sQryName | "_" | SG_VNDR_DEB_AET.PROCESS_INSTANCE;
&aQry = %Session.GetQuery();


If &aQry.Open(&sQryName, True, False) = 0 Then
&rcdQryPrompts = &aQry.PromptRecord;
If &rcdQryPrompts <> Null Then
     &QryRunTimePrompts = &aQry.RunTimePrompts;
     &rcdQryRunParms = CreateRecord(Record.SG_RUN_VNDRDBTS);
     &sqlSelectQryParms = CreateSQL("%Selectall(:1) WHERE OPRID = :2 AND RUN_CNTL_ID = :3");
     &sqlSelectQryParms.Execute(&rcdQryRunParms, %OperatorId, SG_VNDR_DEB_AET.RUN_CNTL_ID);
   While &sqlSelectQryParms.Fetch(&rcdQryRunParms)


          &rcdQryPrompts.GetField(Field.OPRID).Value = &rcdQryRunParms.GetField(Field.OPRID).Value;
          &rcdQryPrompts.GetField(Field.RUN_CNTL_ID).Value = &rcdQryRunParms.GetField(Field.RUN_CNTL_ID).Value;
          Break;
   End-While;
   &sqlSelectQryParms.Close();
End-If;
&Result = &aQry.RunToFile(&rcdQryPrompts, &sOutFile, %Query_XLS, 0);
End-If;
&aQry.Close();


%Session.PSMessagesMode = &nOrigPSMessagesMode;
If %Session.PSmessages.Count = 0 Then
Return True;
Else
&bResult = True;
&PSMessages = %Session.PSmessages;
For &i = 1 To &PSMessages.Count
If (&PSMessages.Item(&i).MessageType <= 1) Then
&bResult = False;
Break;
End-If;
End-For;
Return &bResult;
End-If;
End-Function; /* SG_ExecQuery */


If SG_ExecQuery() = True Then
Exit (0);
Else
Exit (1);
End-If;


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值