Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I would perhaps try running the first 2 queries and storing the results before running the 3rd query. As an example

#!perl use strict; use warnings; use DBI; my $localDB = _dbh(); # build list of ids my $sql1 = << 'SQL1'; SELECT ID FROM A_TEMP2 SQL1 my $sth1 = $localDB->prepare($sql1); $sth1->execute(); my $records = $sth1->fetchall_arrayref(); $sth1->finish; # build list of dblinks my $sql2 = << 'SQL2'; SELECT DBLINK FROM A_TEMP3 WHERE ID = ? SQL2 my $sth2 = $localDB->prepare($sql2); for (@$records){ my $id = $_->[0]; $sth2->execute($id); while ( (my $dblink) = $sth2->fetchrow_array() ){ push @{$_->[1]},$dblink; # many links per id } } $sth2->finish; # process each id-dblink pair for (@$records){ my $id = $_->[0]; for my $dblink (@{$_->[1]}){ my $sql3 = << "SQL3"; SELECT 1 FROM DUAL\@$dblink SQL3 my $sth3 = $localDB->prepare($sql3); if ($DBI::err){ print "Error with PREPARE for $dblink\n"; print $DBI::errstr."\n"; } else { $sth3->execute(); if ($DBI::err){ print "Error with EXECUTE for $dblink\n"; print $DBI::errstr."\n"; } else { my @f = $sth3->fetchrow_array; print "id=$id dblink=$dblink : @f\n"; } } } } $localDB->disconnect; sub _dbh { my $host = "hostname"; my $sid = 'sid'; my $user = 'user'; my $pwd = 'password'; my $dsn = "dbi:Oracle:host=$host;sid=$sid"; my $dbh = DBI->connect($dsn, $user, $pwd, { AutoCommit => 0, PrintError => 0, RaiseError => 0, TraceLevel => 0, # increase as req }) or die "$!"; return $dbh }

In reply to Re^5: Oracle Db Link Error ORA-01001: invalid cursor by poj
in thread Oracle Db Link Error ORA-01001: invalid cursor by mediocremorsov

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (1)
    As of 2021-02-25 03:07 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?