TQuery如何调用Oracle中带传出参数的存储过程? ( 积分: 300 )

  • 主题发起人 主题发起人 kite20020304
  • 开始时间 开始时间
给你个例子:<br>CREATE&nbsp;OR&nbsp;REPLACE&nbsp;PACKAGE&nbsp;BODY&nbsp;PKG_JCCTEST1&nbsp;<br>AS<br>procedure&nbsp;GetSubAndSum2(p1&nbsp;number,p2&nbsp;number&nbsp;,<br>ResultCursor&nbsp;out&nbsp;rc_class)<br>IS<br>BEGIN<br>open&nbsp;ResultCursor&nbsp;for<br>select&nbsp;p1-p2&nbsp;as&nbsp;&quot;sum&quot;,&nbsp;p1+p2&nbsp;as&nbsp;&quot;sub&quot;&nbsp;from&nbsp;dual;<br>END&nbsp;;<br><br>AdoQuery1.Close&nbsp;;<br>AdoQuery1.Parameters.Clear&nbsp;;<br>AdoQuery1.SQL.Clear&nbsp;;<br>AdoQuery1.SQL.Add('{call&nbsp;PKG_JCCTEST1.GetSubAndSum2(?,?)}')&nbsp;;<br>AdoQuery1.Parameters.CreateParameter('P1',ftinteger,pdinput,&nbsp;50,25)&nbsp;;<br>AdoQuery1.Parameters.CreateParameter('P2',ftinteger,pdinput,&nbsp;50,22)&nbsp;;<br>AdoQuery1.Open&nbsp;;<br>Showmessage(string(&nbsp;AdoQuery1.FieldByName('sub').Value)+'-'+<br>string(&nbsp;AdoQuery1.FieldByName('sum').Value));
 
你就用下面的例子写一段代码,调用成功就可以了<br><br>create&nbsp;or&nbsp;replace&nbsp;procedure&nbsp;p_Test&nbsp;(<br>pi_sA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR2,<br>po_sA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OUT&nbsp;VARCHAR2<br>)<br>is<br>begin<br>&nbsp;&nbsp;po_sA&nbsp;:=&nbsp;pi_sA||'&gt;&nbsp;'||TO_CHAR(SYSDATE,&nbsp;'YYYYMMDD');<br>end&nbsp;p_Test;
 
to&nbsp;kite20020304:<br><br>这里有个ADO调用Oracle存储过程的讨论,跟你的问题相似:<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=1321421<br><br>希望有所帮助。&nbsp;[:)]
 
用这个形式:query.add('exec&nbsp;p_Test&nbsp;...')&nbsp;&nbsp;,先执行再打开,就可以得到数据集
 

Similar threads

后退
顶部