use strict; use DBI; my $h = DBI->connect('dbi:mysql:database=test', "xxx", "yyy"); eval { $h->do(q/drop table CUSTOMER_PLAN/); }; $h->do(<do(q/INSERT INTO `CUSTOMER_PLAN` VALUES(1, 'Free', 0, 0.00, 0.75, 'A', '001', 'Try us out - receive 3 free recipes.')/); $h->do(q/INSERT INTO `CUSTOMER_PLAN` VALUES(2, 'Shine', 12, 9.75, 0.75, 'A', '002', 'Shine with a small introduction to Vibrant Healthy Living.')/); $h->do(q|INSERT INTO `CUSTOMER_PLAN` VALUES(3, 'Seeker', 35, 18.75, 0.75, 'A', '003', '-noun. An adventurous person who is seeking new experiences and new information to create a higher level of understanding and enlightenment.')|); $h->do(q|INSERT INTO `CUSTOMER_PLAN` VALUES(4, 'Sage', 60, 47.00, 0.75, 'A', '004', '-noun. A generous, lively person on the journey for the possession of wisdom and experience. This person is energetic, vibrant and famed for health and wisdom.')|); $h->do(q|INSERT INTO `CUSTOMER_PLAN` VALUES(5, 'Guru', 120, 89.00, 0.75, 'A', '005', '-noun. A divine teacher. This person has vast knowledge and practices vibrant living while sharing with their community to create a greater understanding and manifestation of truth and beauty.')|); sub db_err { my ($pmsg, $psql, $perrnum, $perrstr) = @_; print "

There was a problem: $pmsg.

\n"; print "

Attempted command: $psql

\n"; print "

Error: $perrnum - $perrstr

\n"; } my $dbname = 'test'; my $planname = 'Free'; my $sql = "SELECT DCredits, Price, Description FROM $dbname.CUSTOMER_PLAN WHERE Name='$planname'"; my $sqlh = $h->prepare($sql) || db_err("preparing statement handle", $sql, $DBI::err, $DBI::errstr); $sqlh->execute || db_err("executing query", $sql, $DBI::err, $DBI::errstr); #####while (@row = $sqlh->fetchrow_array()) #####{ ##### ($credits, $price, $descript) = @row; ##### # process the data on each loop here #####} #####$sqlh->finish; $h->disconnect;