Assuming that you've created the handle $dbh in the main code, call the subroutine
like
this:
db_statement($dbh);
Then add this first line to the subroutine:
my $dbh = shift;
Skipper
Date sent: Tue, 21 May 2002 08:34:53 -0400
From: [EMAIL PROTECTED]
Subject: DBI "Prepare" Statement Not Working
To: [EMAIL PROTECTED]
> I am brand new to coding with DBI and am trying to set up a simple
> prepare/execute/fetch routine. I'm receiving the following error on my
> prepare statement line: "Can't call method "prepare" on an
> undefined value at ./test.cgi line 51."
>
> Here's is my sub:
>
> sub db_statement
> {
> my $sth = $dbh->prepare("select rollup_code, rollup_value, french_flag
> from FMC_REPORT_CREATE_PARAMS
> where aggr_rpt_id = 2
> order by report_seq_num");
> $sth->execute;
>
> while ( @row = $sth->fetchrow_array ) {
> print "@row\n";
> }
> }
>
> Can anyone tell me what I'm doing wrong with the prepare statment?
> Thanks! Deb Vredeveld
>
>