DELPHI invokes an Oracle stored procedure and returns an example of a dataset.

Source: Internet
Author: User
Tags integer
oracle| Stored Procedures | Data Environment: WIN2000 + Oracle92


First, build a package in Oracle
CREATE OR REPLACE PACKAGE pkg_test
As
TYPE Myrctype is REF CURSOR;
PROCEDURE get (i_test integer,p_rc out myrctype);
End Pkg_test;

CREATE OR REPLACE PACKAGE body pkg_test
As
PROCEDURE get (i_test integer,p_rc out Myrctype) is
BEGIN
IF i_test = 0 THEN
OPEN P_RC for SELECT sysdate from dual;
ELSE
OPEN P_RC for SELECT * from Tab;
End IF;
End get;
End Pkg_test;

Second, with Delphi call
Build a form and drag controls AdoConnection1, ADOStoredProc1, and Button1.
Procedure Tform1.button1click (Sender:tobject);
Begin
Try
With ADOConnection1 do
Begin
connectionstring:=
' Provider=oraoledb.oracle.1; '
+ ' password= password; '
+ ' Persist security info=true; '
+ ' user id= username; '
+ ' data source= database name; '
+ ' Extended properties= ' plsqlrset=1;
Open;
End
Except
ShowMessage (' connection unsuccessful ');
Exit
End

Try
With ADOStoredProc1 do
Begin
Connection: = ADOConnection1;
Parameters.clear;
procedurename:= ' Pkg_test.get ';
Parameters.createparameter (' P1 ', ftinteger,pdinput,10,1);
Open;
End
Except
ShowMessage (' Unable to execute process. ');
End
End


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.