On 03/03/2011 17:16, vito pascali wrote:

I'm really new to perl and programmation too so don't bear on me if I will
say something wrong pls... :)

The problem:

I have 3 querys to 2 different oracle databases:


1)script query G1:

#!/usr/bin/perl -w
use DBI;
use warnings;
my ( $db );

$db = DBI->connect( "dbi:Oracle:host=x.x.x.x;sid=XX", "x", "x" )
    || die( $DBI::errstr . "\n" );

my $SEL_G1 = "select x,y from table";

my $query_handle = $db->prepare($SEL_G1);

$query_handle->execute();
$query_handle->bind_columns(undef,\$x, \$y);
while (my @result_g1 = $query_handle->fetchrow_array){
print "$x-$y\n";
}
$db->disconnect if defined($db);

This print:
1@1600@1@1600A@1@alfa@ 1-10125691-20110301102500


-------------------------------------------------

2)script Query G2:

#!/usr/bin/perl -w

use DBI;
use warnings;
my ( $db2);
$db2 = DBI->connect( "dbi:Oracle:host=x.x.x.x;sid=XX", "x", "x" )
|| die( $DBI::errstr . "\n" );

my $SEL_G2 = "select x from table";

my $query_handle_2 = $db2->prepare($SEL_G2);

$query_handle_2->execute();
$query_handle_2->bind_columns(undef,\$x);
while (my @result_gal = $query_handle_2->fetchrow_array){
print "$x\n";
}
$db2->disconnect if defined($db2);

This print:
1@1501@1@1501CPL1@1@alfa


----------------------------------------------------------

3) Query L1:

#!/usr/bin/perl -w

use DBI;
use warnings;
my ( $db1 );

$db1 = DBI->connect( "dbi:Oracle:host=x.x.x.x;sid=YY", "y",
"y")
     || die( $DBI::errstr . "\n" );

my $SEL_L1 = "select x,y from table"

my $query_handle_1 = $db1->prepare($SEL_L1);

$query_handle_1->execute();

$query_handle_1->bind_columns(undef,\$x, \$y);
while($query_handle_1->fetch()) {
         print "$x-$y";
         print "\n";
}
$db1->disconnect if defined($db1);

This print:
1@1206@1@1206@1@alfa@    1-10123745-20110303162900

I need that the results from the query L1 is checked against the results
from the query G1 and that what differs between will be checked finally
against the results of G2.
The problems are:

1)the results are huge, specially what come from G1;
2)2 of the 3 arrays (@G1 e @L1) and one not (@G2);
3)I'm really a newbie....

So what would be for you the best (and the fastest) way to do the job?
Example,link and RTFM are really appreciate!

You haven't told us enough to understand the problem. You are performing
'select x,y from table' and want to "check it against" the results of
'select x from table'. I can assure you that it will be the same but
with an extra column in the first set.

Are 'x', 'y', and 'table' different in each case perhaps? If so then you
must explain in detail what you mean by 'check against'. It is likely
that any comparison between the two results from the same database can
be performed in SQL. Depending on how you have Oracle set up, you may be
able to do the same with the third set.

What is the purpose of the initial 'undef' in your calls to
bind_columns? If your code is genuinely as you have shown it, then the
value of x will be discarded. Also, the output you show doesn't look
like it came from the print statements you are using.

Could you explain better what it is you are trying to achieve please?

Rob

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to