Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2022-08-19 14:29 GMT
Find Nodes?
    Voting Booth?

    No recent polls found