Re: Fetching values in Perl

Greg Meckes <[email protected]> Fri, 28 Sep 2007 07:19:38 -0700 (PDT)
Newsgroups gmane.comp.db.mysql.perl
Message-ID <[email protected]>
Perhaps you could do it like this:

$dbh= DBI->connect("dbi:mysql:dbname=$database;host=$hostname",
 "$username",
"$password");

# Do some checking and untainting with $ARGV[0]
# I wouldn't just pass an argument like that
# directly to a query.

my $arg = $ARGV[0]; # Check it here

$statement = "SELECT patient_intime from $table_name where patient_intime=$arg)";

my $sth = $dbh->prepare($statement) or die "Couldn't execute statement: " . $sth->errstr;
$sth->execute;

my @data = ();

while (@data = $sth->fetchrow_array()) {
$patient_intime = $data[0];
}

--- padmaja <[email protected]> wrote:

> 
> Hi all,
> I have written a query like this.
> ----------------------------------------------------------
> 
> $dbh= DBI->connect("dbi:mysql:dbname=$database;host=$hostname", "$username",
> "$password");
> 
> $statement = "SELECT patient_intime from $table_name where
> patient_intime=$ARGV[0])";
> 
> 
> ----------------------------------------------------------
> I want all the "patient_intime" values to be retreived, where there are
> other columns(fields) also. 
> Pls suggest me how to proceed.
> 
> Thanks in advance.
> Padmaja T N.
> -- 
> View this message in context:
> http://www.nabble.com/Fetching-values-in-Perl-tf4534430.html#a12940280
> Sent from the MySQL - Perl mailing list archive at Nabble.com.
> 
> 
> -- 
> MySQL Perl Mailing List
> For list archives: http://lists.mysql.com/perl
> To unsubscribe:    http://lists.mysql.com/[email protected]
> 
> 


-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/[email protected]