[rochester-pm-list] DBI-DBD and Oracle
Fred Edmister
fedm at pkcommunications.com
Wed Dec 1 11:39:28 CST 1999
At 12:25 PM 12/1/99 -0500, you wrote:
Ok... Here's the code... :)
{begin code}
use DBI;
my $dbh = DBI->connect('DBI:Oracle:pkcom2','username','passwd')
or die "Couldn't connect to database: " . DBI->errstr;
my $sth = $dbh->prepare('SELECT * FROM stores_master WHERE store_id = ?')
or die "Couldn't prepare statement: " . $dbh->errstr;
print "Enter name> ";
while ($lastname = <>) { # Read input from the user
my @data;
chomp $lastname;
$sth->execute($lastname) # Execute the query
or die "Couldn't execute statement: " . $sth->errstr;
# Read the matching records and print them out
while (@data = $sth->fetchrow_array()) {
my $firstname = $data[1];
my $id = $data[2];
print "\t$id: $firstname $lastname\n";
}
if ($sth->rows == 0) {
print "No names matched `$lastname'.\n\n";
}
print "\n";
print "Enter name> ";
}
$sth->finish;
$dbh->disconnect;
{end code}
At this point, it's just a "hacked" version of the example from where I
got the files.. I've managed to make it connect... Now I'm getting that
error...
Thank you very much! :)
>ORA-01722 error indicates a failed conversion of a character string to a
number.
>It's likely that the insert statement in misordered. Be sure that the
columns match up
>correctly.
>
>It's also possible that you didn't strip a '$' of a currency amount or
something similar.
>
>If you post your code, I'd be able to help more.
>
>Hope this helps,
>
>--Pat Ludwig
>
>
Fred Edmister
PK Communications
CGI Web Developer
fedm at pkcommunications.com
More information about the Rochester-pm
mailing list