in reply to Get multiple rows in Perl from Oracle

As Corion suggests, this is covered in detail within the DBI documentation. See also Reading from a database from the tutorials section, but the documentation should be more than sufficient.

Martin

  • Comment on Re: Get multiple rows in Perl from Oracle

Replies are listed 'Best First'.
Re^2: Get multiple rows in Perl from Oracle
by kalyanrajsista (Scribe) on Dec 24, 2009 at 11:54 UTC
    I agree that DBI does lots of things, but I'm trying to execute a stored procedure which returns data rows. I'm successfully executing procedure and is returning only the last row from DB output. How can i get all the rows I'm trying the following modules....
    use DBIx::Connection; use DBIx::PLSQLHandler;

      The documentation seems fairly explicit. You could show us some code, but that would spoil the fun of extracting the relevant information piece by piece from you.

      So, my next question is, is it a mineral?

        Here is my code

        use strict; use warnings; use DBIx::Connection; use DBIx::PLSQLHandler; my $Datasource = "dbi:Oracle:sid=dev;host=10.11.12.13"; my $connection = DBIx::Connection->new( name => 'dev', dsn => $Datasource, username => 'scott', password => 'tiger', ); my $plsql = $connection->plsql_handler( plsql => "DECLARE TYPE group_type IS RECORD ( h1 groups.HANDLE_GROUP%TYPE, g1 groups.GHANDLE%type); group_rec group_type; CURSOR data_groups IS SELECT DISTINCT ghandle FROM groups; BEGIN OPEN data_groups; FETCH data_groups INTO group_rec.g1; WHILE data_groups % FOUND LOOP SELECT handle_group INTO group_rec.h1 FROM groups WHERE ghandle = group_rec.g1 AND rownum < 2; DBMS_OUTPUT.PUT_LINE(group_rec.g1 || '==>' + || group_rec.h1); :h2 :=group_rec.h1; :g2 :=group_rec.g1; FETCH data_groups INTO group_rec.g1; END LOOP; CLOSE data_groups; END;" ); my $result_set = $plsql->execute(); print Dumper($result_set);

        The above code is returning only one record, but when I execute my procedure in SQL Developer it is outputting many records

        Any problem in my procedure...though