Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi







Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (1)


Retrieve Multiple Recordsets from ORACLE 8i Stored ProcedureFormat this article printer-friendly!Bookmark function is only available for registered users!
Using Delphi ADO Components and Oracle OLE DB
Product:
Delphi 5.x (or higher)
Category:
ADO/OLE-DB
Skill Level:
Scoring:
Last Update:
09/09/2002
Search Keys:
delphi delphi3000 article borland vcl code-snippet ADO Oracle Recordsets Rowsets odbc adoexpress mdac OLE- DB database odbc
Times Scored:
11
Visits:
8261
Uploader: hagay azar
Company:
Reference: N/A
 
Question/Problem/Abstract:
A Faster and more resource efficient way to get data from the Database server (in this case - Oracle)
Answer:



Orace OLE DB supports Multiple Rowsets from version 8.1.7.0.0 and above.


// Oracle DB Preparations:

Create this package at the default "Scott" user.

--------------------------------------------------------------------

CREATE OR REPLACE PACKAGE TEST_PACKAGE AS

      TYPE GenericCursor IS REF CURSOR;

   PROCEDURE TEST_PROC (out_DEPT_TEST_cursor OUT GenericCursor,
out_EMP_TEST_cursor OUT GenericCursor);

END;
/

CREATE OR REPLACE PACKAGE BODY TEST_PACKAGE AS

   PROCEDURE TEST_PROC (out_DEPT_TEST_cursor OUT GenericCursor,
out_EMP_TEST_cursor OUT GenericCursor) AS
   BEGIN
   OPEN out_DEPT_TEST_cursor FOR SELECT * FROM DEPT;
   OPEN out_EMP_TEST_cursor FOR SELECT * FROM EMP;
   END;
END;
/

--------------------------------------------------------------------

The procedure "TEST_PROC" will open two cursors one by one :

first  - All of DEPT table's records
second - All of EMP table's records


// Delphi Application :


Create new Application with DataModule and save it.
Add the Datamodule to the form's USES list.

Drop a button and two Memo Components into your form.
Drop ADOConnection, ADOCommand, ADODataSet Components into your DM.

Connect the ADOCommand to the ADOConnection using the ADOCommand's "Connection" property.

Build the ADOConnection's Connection String (Connect to the Scott Schema)

Your Connection string should look like that:

Provider=OraOLEDB.Oracle.1;Persist Security Info=False;User ID=scott;Data Source=MY_DataSource;Extended Properties="plsqlrset=1"

Pay Attention that the Extended Properties MUST contains the "plsqlrset=1"
You can either add it manually to the connection string or Add it like this :
Dbl Click on the ADOConnection Component, push the 'Build' button, Goto the 'All' Tab and put
there - plsqlrset=1 (no need for the quotation marks there)

Configure ADOCommand :
Set CommandType property to 'cmdStoredProc'
Set CommandText property to 'TEST_PACKAGE.TEST_PROC'

--------

This is the Button's Click procedure -

procedure TForm1.Button1Click(Sender: TObject);
begin
  with DataModule1 do
  begin
    ADODataSet1.Recordset := ADOCommand1.Execute;
    while NOT ADODataSet1.Eof do
    begin
      Memo1.Lines.Add(ADODataSet1.FieldByName('DNAME').AsString);
      ADODataSet1.Next;
    end;

    ADODataSet1.Recordset := ADODataSet1.Recordset.NextRecordset(EmptyParam);

    while NOT ADODataSet1.Eof do
    begin
      Memo2.Lines.Add(ADODataSet1.FieldByName('ENAME').AsString);
      ADODataSet1.Next;
    end;
  end;
end;

--------

Memo1 will be filled with department names
Memo2 will be filled with employee names








Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
do it
    David.W (Nov 9 2004 1:57AM)

from china,i am every live delphi.
Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
R. Lefter
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)