Thanks much Stuart, understood. regards.
________________________________ From: Stuart Cooper <stuart.coo...@gmail.com> To: Rajeev Prasad <rp.ne...@yahoo.com> Cc: "dbi-users@perl.org" <dbi-users@perl.org> Sent: Friday, July 29, 2011 5:21 PM Subject: Re: question on CPAN example for DBI Hi Rajeev, $baz is a variable that gets substituted for the ? in the prepare statement, between the $dbh->prepare() and the $sth->execute. So it's really: $sth = $dbh->prepare("SELECT foo, bar FROM table WHERE baz=?"); ... extra lines here... calculating $baz $sth->execute( $baz ); Read a bit further down in perldoc DBI and you should hit a paragraph saying The "?" characters are placeholders... You don't have to use ? placeholders if you know well in advance what you're looking for and you don't want to run that same query multiple times with different baz values. $sth = $dbh->prepare("SELECT foo, bar FROM table WHERE baz=5"); $sth->execute(); is fine. Hope this helps, Stuart. On Sat, Jul 30, 2011 at 8:13 AM, Rajeev Prasad <rp.ne...@yahoo.com> wrote: > Hello, > > I am trying to understand this code from CPAN hepl page: > > > > $sth = $dbh->prepare("SELECT foo, bar FROM table WHERE baz=?"); > $sth->execute( $baz ); while ( @row = $sth->fetchrow_array ) { print > "@row\n"; } > > > what is execute doing here with $baz? what is $baz representing? > > thank you. > Rajeev >