in reply to Date Problem

my $SQL ="Select tran_seq_nbr, sale_amount From Header Where org_numbe +r = 8 And store_number = 3 And tran_number = 2127 And terminal_number + = 8 And tran_Date = to_date(?,'YYYY-MM-DD HH24:MI:SS')"; $sth->execute($date) or die $sth->errstr;

Let me try that again, obviously I can't concentrate on sending a sms at the same time as answering your post :P

my $SQL ="Select tran_seq_nbr, sale_amount From Header Where org_numbe +r = 8 And store_number = 3 And tran_number = 2127 And terminal_number + = 8 And tran_Date = to_date(?,'YYYY-MM-DD HH24:MI:SS')"; $sth->prepare($SQL); $sth->execute($date) or die $sth->errstr;

See the section on placeholders from the DBI documentation.

Update: Fixed my reply, not enough caffeine on a Monday morning while trying to do two things at once :P

Replies are listed 'Best First'.
Re^2: Date Problem
by Anonymous Monk on Apr 26, 2010 at 09:55 UTC
    my $SQL = "Select tran_seq_nbr, sale_amount From KCPOS_Tran_Header Where org_number = $ai_div And store_number = $ai_store And tran_number = $al_trans And terminal_number = $ai_reg And tran_Date = $adt_h_date"; my $sth = $dbh->prepare( $SQL ) or die "Couldn't prepare statement: " . $dbh->errstr; $sth->execute() or die "Couldn't execute statement: " . $sth->errstr; ( $ac_seq_nbr, $ac_sale_amount ) = $sth->fetchrow();

    This what i am doing

      I don't know where you're getting the contents of $adt_h_date, but did you read the section on placeholders from the DBI docs? You want to use placeholders to protect against SQL injection. I'd suggest looking this up in the documentation.

      I think the problem is because of not quoting the date value($adt_h_date) in the query preparation.