madhatter has asked for the wisdom of the Perl Monks concerning the following question:
The idea is to get it to automatically handle the errors. The connect and error subs work.sub db_execute { my(@return,@a,$cursor); unless($VARS{connected}){db_connect();$VARS{connected}++;} undef @return; $cursor = $dbh->prepare($_[0]); $cursor->execute || db_error(); unless($_[1]){ while (@a = $cursor->fetchrow){push (@return,@a)} return (@return); } }
What I want to do is push to @return a reference (I think) to @a, so later I can call something along the lines of:
What changes do I have to make above to get this to work?my $SQL = "select a,b,c from table"; my @lines = db_execute($SQL); while( ($a,$b,$c) = @lines ){ .. }
Thanks,
madhatter
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Weird DBI/Array Use
by salvadors (Pilgrim) on Jan 08, 2001 at 01:28 UTC | |
|
Re: Weird DBI/Array Use
by chipmunk (Parson) on Jan 08, 2001 at 01:24 UTC | |
|
Re: Weird DBI/Array Use
by madhatter (Sexton) on Jan 08, 2001 at 03:29 UTC | |
by Fastolfe (Vicar) on Jan 08, 2001 at 03:48 UTC | |
by repson (Chaplain) on Jan 08, 2001 at 08:21 UTC |