Results 1 to 28 of 28

Thread: Resultset from Oracle

  1. #1

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Resultset from Oracle

    Hi

    Somebody have a examples How can I to return Resultset from Oracle to Visual Basic.
    I trying with Ref Cursor, but I need to do others call to others Tables and Return data to a Recordset of the VB

  2. #2

  3. #3

  4. #4
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Recordset from Oracle - Examples

    Well if you rprocedure returns record then just execute it from VB and set the return value to a recordset.

    Have I misunderstood what You are trying to say?
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  5. #5

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Recordset from Oracle - Examples

    thanks
    RhinoBull
    I neeed return a Resultset for VB, for to open with recordset
    Shuja Ali
    Do You have a example ?

  6. #6

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Resultset from Oracle

    Sorry

    I do not to knew where I to post

    Sorry again

  7. #7
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Recordset from Oracle - Examples

    A simple example would be using a Command Object of the ADO library and execute the procedure using that.

    I guess a simple search on this forum will give you lot of examples.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  8. #8
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Recordset from Oracle - Examples

    Look in the Database section FAQ (this is the thread: http://www.vbforums.com/showthread.php?t=393457)). I have posed examples using VB6 and VB.Net for this.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  9. #9

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Unhappy Re: Recordset from Oracle - Examples

    Thanks

    But I need Passing Data from 2 or 3 Cursors, as below

    cursor c1 (v1 in integer....) is
    select a, b, c
    from Table A, TAble B
    WHERE ANYthing

    cursor c2 (v2 in integer...etc) is
    select x1,x2 , x3
    from tableX, TableY
    where ANYTHING
    FOR R_C1 IN C1 (V1.....Vn) loop
    FOR R_C2 IN C1 (V1.....Vn) loop
    I NEED TO MOUNT A RESULT SET WITH some data from c1 cursor
    and other data from c2 cursor



    end loop

    end loop

    How can to build a Resultset like above ?

  10. #10
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Recordset from Oracle - Examples

    Record sets can contain more the on result right. So create another input/output parameter for the SP and Return the results from the other cursors to the parameters,
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  11. #11

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Recordset from Oracle - Examples

    Hi

    I do not understand , because I have 2 Cursors nested, where the second use data from first, but I need return some data from 2 Cursors

    Example

    LOop cursor c1
    loop cursor c2 with data from c1

    end loop c2
    end loop cursor c1

    I want return a cursor C to VB with some data from c1 and some data from cursor c2

  12. #12
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Recordset from Oracle - Examples

    As I said create two reference cursors. set the results of the SP cursors to the two refecursors and return the two ref cursors to the application in on record set. You can then use the record set to break up the results.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  13. #13

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Recordset from Oracle - Examples

    I do not to do

  14. #14
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Re: Resultset from Oracle

    If u r referring to vb.net it is easy.

    Just declare a procedure like this:

    craete or replace procedure P_TEST(param1 in varchar2, recordset out cursor)

    open recordset for

    select * from whatever

    end procedure P_TEST;


    I wrote this by heart... but I hope you get a general idea.

    What I did to make things easier was to encapsulate the cursor into a TYPE. I can show u the code when I get back to office...

    /Henrik

  15. #15
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Recordset from Oracle - Examples

    When you have the results back in VB then use the rs.nextresult command.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  16. #16

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Resultset from Oracle

    tks

    for a simple SELECT this work fine, but I have 2 or 3 Cursors for return in only recordset

  17. #17

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Recordset from Oracle - Examples

    tks

    How can I read The first row from first recordset and first row from Second recordset

    After

    read The Second Row from first recordset and Second row from Second Recordset ?

  18. #18
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Resultset from Oracle

    Quote Originally Posted by RhinoBull
    Please do not dbl post. Thank you.
    Duplicate Threads merged.

  19. #19
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Resultset from Oracle

    You must process each record set to completion then move to the next.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  20. #20

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Resultset from Oracle

    Ok

    But I need first row from first cursor together with first row from second cursor

  21. #21
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Resultset from Oracle

    Then I think we need to look at chaning the way data is gathered. Why draw the data you need from 2 cursors in Oracle and not just one? Or return the return the results from the first cursor and then call a second SP with data in the result set from the first SP (in a resultset).
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  22. #22

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Resultset from Oracle

    Do you have a example ?

  23. #23
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Resultset from Oracle

    Since I don't know what you're tying to accomplish no. Why not write two SPs. The first one returns the result set bound in our first cursor of the original SP. Now once back into the app call a second SP that has the reults based on the results of the first, and return that set.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  24. #24

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Resultset from Oracle

    Tks

    I will go try

  25. #25

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Unhappy Re: Resultset from Oracle

    I did not have success

  26. #26
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Resultset from Oracle

    What did you not have success at?
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  27. #27

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Resultset from Oracle

    to do a procedure that return in only cursor, with call for other procedure with other 2 cursors

    I need to build a procedure with only cursor, because I to return to VB or Crystal reports

  28. #28
    New Member
    Join Date
    May 2008
    Posts
    1

    Resolved Re: Resultset from Oracle

    Hello,

    I'm not sure I've understood exactly what mutley was trying to do, but I'm also trying to get, in my VB project, 2 or more REF CURSORS from a packaged procedure in Oracle, and it gives me the following error:

    Error Type:
    ADODB.Recordset (0x800A0CB3)
    Current provider does not support returning multiple recordsets from a single execution.

    Here's a bit of the code:
    ----------------
    SQL = "{? = call PK.procXPTO({resultset 0, refCursor1},{resultset 0, refCursor2},?)}
    (...)
    .CommandType = adCmdText
    .NamedParameters = True
    Set objParam = .CreateParameter("result", 131, 2)
    .Parameters.Append objParam
    Set objParam = .CreateParameter("paramIN", 131, 1, 255, paramIn)
    .Parameters.Append objParam
    (...)
    ---------------

    I'm using MSDAORA as Provider, Oracle 9.2 and VB6.

    Any help is utterly appreciated.

    Many thanks,

    E. V.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width