[ale] brain damaged perl DBI
Geoffrey
esoteric at 3times25.net
Fri Jan 28 06:34:29 EST 2005
James P. Kinney III wrote:
> This *&%*^ chunk of perl is not returning anything from the database. Is
> there something stupid I have missed (The data is there. A psql query
> return two lines which is correct. It does connect to the database as I
> copied the connection params from another working area).
>
> # connect to database
> my $dbh = $form->dbconnect($myconfig);
> my $id_start = $form->{id};
> my @clone_list;
> my %clone_test;
> push @clone_list, $id_start;
> $clone_test{$id_start} = 1;
> foreach my $id (@clone_list){
> my $query = qq|SELECT id
> FROM assembly
> WHERE parts_id = $id|;
I believe you'll need single quotes around $id above.
> my $sth = $dbh->prepare($query);
> $sth->execute || $form->dberror($query);
> my $ref;
> while ($ref = $sth->fetchrow_arrayref){
> my $cloneid = [ @$ref ];
> if ((! $clone_test{$cloneid}) && ($cloneid !~ $id_start)){
> push @clone_list, $cloneid;
> $clone_test{$cloneid}=1;
> }
> }
> $sth->finish;
> }
> $dbh->disconnect;
> open (OUT, ">/tmp/out.IC")||die "$!\n";
> my $line = join ', ', @clone_list;
> print OUT "clone_list = $line\n";
> close OUT;
> push @{ $form->{clone_list}}, @clone_list;
>
>
> The file /tmp/out.IC gets only "clone_list = 0" ?!?!?!
>
> I added prints to the while ($ref.....) block and got nothing. If I add
> a die in the while block, it dies at that point. so I know it's running.
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
--
Until later, Geoffrey
More information about the Ale
mailing list