The most likely reason for your SQL query to fail is perhaps the null values in the columns. nvl(xxx,default) will return the default value if xxx is null.$dbh=$db->prepare("SELECT nvl(mb_award,0.00), nvl(mb_accept,0.00) FROM Items WHERE itemnum=? AND seller=? AND closef='1'"); $dbh->execute($form{'item'}, $fdnum); my ($mb_award,$mb_accept) = $dbh->fetchrow_array(); my $mb_amount_disp = $mb_award > 0.00 ? $mb_award : $mb_accept > 0.00 ? $mb_accept : 0.00; # Assume you have negative values
use strict; use DBI; use DBD::Oracle qw(:ora_types); # Connect as Oracle $ENV{ORACLE_HOME}='/users/oracle/OraHome1'; my $dbh=DBI->connect("dbi:Oracle:MyDatabase","username","password"); # Select the some columns from the database my $sth = $dbh->prepare("select a as Alias, b as Bob from MyTable where c=?"); $sth->execute("Some Value"); # One convenient method is to use a hash reference while (my $res = $sth->fetchrow_hashref()) { # You can refer to values using the name of the column/alias # for example... my $alias = $res->{Alias}; my $bob = $res->{Bob}; .... } $sth->finish; $dbh->disconnect();
In reply to Re: DBI compare columns problem
by Roger
in thread DBI compare columns problem
by th3monk3y
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |