时间:2021-07-01 10:21:17 帮助过:2人阅读
然后写qtp测试
‘——————————————————————————————————————————— ????‘名称:oracle_nextAPPROVEID ????‘作用:数据库中查询出下一步审批人 ????‘参数:FormID ????‘返回:下一步审批人 ????‘使用:QTP.oracle_nextAPPROVEID("-") ????Function?oracle_nextAPPROVEID(FormID) ??????? ????????Dim?Cnn??‘定义一个数据库连接串 ????????Dim?Rs ????????Dim?sql ????????Dim?uid ????????Set?Cnn?=?CreateObject("ADODB.Connection") ????????Cnn.Open?="Provider=OraOLEDB.Oracle.1;Persist?Security?Info=False;User?ID=BPMUSER2;;Password=BPMUSER2;Data?Source=CEDATA" ???????? ????????If?Cnn.State?=?0?Then??????‘判断数据库连接是否成功 ????????????Report.Debug("[Cnn.State]?Cnn.State?=?"?&?Cnn.State) ????????????Report.FunctionOut("[Cnn.State]?Cnn.State?=?"?&?Cnn.State) ????????????Exit?Function ????????????End?If ????????If?Cnn.State<>?0??Then???? ????????Report.Debug("[Cnn.State]?Cnn.State?=?"?&?Cnn.State)??? ????????Set?Rs=CreateObject("ADODB.Recordset")????‘生成记录集对象 ????????‘FormID=?chr(34)&FormID&chr(34)? ????????Report.Debug("[FormID]?FormID?=?"?&?FormID)??? ????????sql?="select?*?from(select?b.ID,a.PROCESSID,APPROVEID?from?FORM_MASTER_INFO?a?inner?join?FORM_HISTORY_INFO?b?on?a.PROCESSID=b.PROCESSID?and?a.FORMRESULT=‘N‘?WHERE?a.PROCESSID=?‘"&FormID&"‘??order?by?b.ID?desc)?where?rownum=1" ?????????Report.Debug("[sql]?sql?=?"?&?sql) ?????????On?Error?Resume?next? ????????Rs.Open?sql?,Cnn,1,3??‘执行sql语句,记录可以自由移动,单数记录处于只读模式???????? ????????uid=Rs("APPROVEID")?‘取得字段为custid的记录,游标定义在第一行,所以取得的是该字段所在行的第一行数据 ????????Report.Debug("[uid]?uid?=?"?&?uid) ????????oracle_nextAPPROVEID?="("&?uid&")"???????????? ????????‘msgbox?uid ????????End?If ????End?Function
调用一下,就可以完成了;做的完善点需要关闭连接等等
RS.close ‘关闭记录集
Set RS=nothing ‘释放对象
Cnn.Close ‘关闭数据连接
Set Cnn=nothing ‘释放对象
这些都是后话了。
QTP连接oracle
标签: