in reply to Re: Re: Re: DBD::CSV and SQL::Statement
in thread DBD::CSV and SQL::Statement

Ok, first on SQL::Statement "the basic design ... allows joins". Yeah, right. The design allows it and if you want to implement it, all you have to do is implement it. :-) It's on my to-do list but it is not an easy task.

Now for the example of accomplishing joins with multiple statement handles (this uses DBD::AnyData which is newer than DBD::RAM but except for the slightly different "catalog" syntax, it's the same with DBD::RAM:

my $dbh=DBI->connect('dbi:AnyData(RaiseError=>1):');
$dbh->func( 'Class', 'Pipe', 'class.tbl', 'ad_catalog');
$dbh->func( 'Reg', 'Pipe', 'reg.tbl', 'ad_catalog');
my $class_sth = $dbh->prepare( qq{SELECT cid,cname FROM Class} );
my $reg_sth = $dbh->prepare( qq{SELECT sid FROM Reg WHERE cid = ?} );
$class_sth->execute;
while (my($cid,$cname) = $class_sth->fetchrow_array) {

$reg_sth->execute($cid);
my $sid = $reg_sth->fetchrow_arrayref->[0];
print "$cid : $cname : $sid\n";
}

That will produce the same list that this statement would:

SELECT Class.cid, Class.cname, Reg.sid
FROM Class, Reg
WHERE Class.cid = Reg.cid

  • Comment on Re: Re: Re: Re: DBD::CSV and SQL::Statement