2005/9/26, Thomas Zake <[EMAIL PROTECTED]>:
> Hi,
>
> assume, we have the two tables T1 and T2:
> CREATE TABLE T1 ( K1 VARCHAR(3), PRIMARY KEY (K1) )
> CREATE TABLE T2 ( K1 VARCHAR(3), K2 VARCHAR(3), PRIMARY KEY ( K1, K2 ) )
>
> with the following contents:
> T1:    K1                            T2:   K1  | K2
>         -----                                 -----------------
>           001                                  002 | 001
>           002
>
> and the following script:
>
>  #!/usr/bin/perl
>
> use strict;
> use warnings;
> use DBI;
>
> my  $dbh = DBI->connect("dbi:MaxDB:....",...);
>
> my $sth1 = $dbh->prepare("Select k1 From t1");
> my $sth2 = $dbh->prepare("Select k2 From t2 Where k1 = ?");
> $sth1->execute;
> while ( my ( $k1 ) = $sth1->fetchrow_array ) {
>   print ">T1 - $k1\n";
>    $sth2->execute( $k1 );
>    while ( my ( $k2 ) = $sth2->fetchrow_array ) {
>       print ">>>T2 - $k1 $k2\n";
>    }
> }
> $sth1->finish;
> $sth2->finish;
> $dbh->disconnect;
>
> The Result is:
> >T1 - 001
> >T1 - 002
>
> and not as expected:
> >T1 - 001
> >T1 - 002
> >>>T2 - 001 002
>
> After the first execute of $sth2 with an empty result set, the result set of
> $sth2 is always empty.
>
> Used with DBD::MaxDB 7.6.00.16a with SQLDBC 7.6.00.12 on SuSE 9.3 with MaxDB
> 7.5.21
>
> Any ideas?

Are you sure that you can execute two prepared statements on the same
connection at the same time?  I know there are limitations with some
RDBMS' although I don't know whether MaxDB or the DBD for MaxDB is one
of them.

Another cause might be character conversion issues so that $k1 is not
recognized as key in T2.

I don't know your business requirements but you might also get away
with a single join on both tables ordered by T1.K1 - at least that's
what I'd do in this scenario.  You just need a single iteration and if
you want to do something once for every key in T1 you just need to
watch it change and only act then.

My 0.02EUR...

Kind regards

robert

--
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to