Re: Problem with selecting rows from a database link



On Monday 17 Sep 2007, Crosbourne, Rainaldo wrote:
Hey guys



I am trying to query a table using a database link, using the following
code:



use strict;



use DBI;



my $col_value = 'test';

my $query = 'select col_1,col_2,col_3 from table_name@link_name where
col_1 = ?';



my $dbh = DBI ->connect ('dbi:Oracle:dbs','username','password',{
RaiseError => 1, AutoCommit => 0 }) || die "Database connetion not made:
$DBI::errstr";



my $sth = $dbh->prepare ($query)|| die "Unable to prepare\n";



$sth->execute($col_value) or die "Can't execute SQL statement:
$DBI::errstr Stopped\n";

my ($col_1,$col_2,$col_3);



$sth->bind_columns(\($col_1,$col_2,$col_3))||die "Unable to fetch\n";



print "$col_1: $col_2 :$col_3\n" while $sth1->fetchrow_arrayref;



$dbh->disconnect;



Now what happens is that, the first time this program is run, it returns
the correct result. However after the first successful run it fails to
run again. It gives NO error, it just fails to return the rows. If a
create a new link and use the new link in the query, it then works for
the first run, and then fails after. The same thing happens if I decide
to query a view that was created using the link.

A thought. Are you using persistent perl or perhaps Apache's mod_Perl?

Because if you are, then variables will stay in the same state they were in
when the previous run ended rather than being re-initialised when you re-run
(unless you explicitly initialise them)

It sounds like the kind of "gotcha" I've had trouble with in the past using
persistent perl.



--
Tony Green
Ipswich, Suffolk, England
http://www.beermad.org.uk
http://no2id-ip.web-brewer.co.uk
.



Relevant Pages

  • Re: PHP + MySQL + Queries that depend on each other?
    ... if echo mysql_error; ... If it fails, it will display the succeeded error. ... Should this procedure be done every time a query is done, or, ... or take down the server between queries. ...
    (comp.lang.php)
  • Re: query from form
    ... The following forces the type of test to be a string. ... I have a question about applying to this to a query within a report. ... The query that fails refers to the text box on the form. ...
    (microsoft.public.access.queries)
  • Problem with selecting rows from a database link
    ... I am trying to query a table using a database link, ... it just fails to return the rows. ... DBI version = 1.59 ...
    (perl.dbi.users)
  • Re: Decimal fieldss precision is too small to accept the numeric you attempted to add
    ... Your test query, as is, works fine. ... Can't understand why the same expression does not work in MY query. ... Tried putting the Cdbl) around both of those, still fails. ... If they are queries, you may need to perform the typecasting in the lower queries. ...
    (microsoft.public.access.queries)
  • Re: Date not within range query
    ... When Name Autocorrect works it is nice. ... can cause problems and often fails to work. ... Now use that and your entities table to do an unmatched query. ... have no linked records that fall inside a date range. ...
    (microsoft.public.access.queries)