in reply to Date Problem

Please show us the code where you actually execute the query.

Replies are listed 'Best First'.
Re^2: Date Problem
by Anonymous Monk on Apr 26, 2010 at 09:35 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 is what i am doing

      The correct way of passing arguments to DB queries is to use placeholders:
      my $SQL = Select tran_seq_nbr, sale_amount From KCPOS_Tran_Header Where org_number = ? And store_number = ? And tran_number = ? And terminal_number =? And tran_Date = ?"; my $sth = $dbh->prepare( $SQL ) or die "Couldn't prepare statement: " . $dbh->errstr; $sth->execute($ai_div, $ai_store, $al_trans, $ai_reg, $adt_h_date ) or die "Couldn't execute statement: " . $sth->errstr;

      That way you can avoid quoting errors which might cause your problem.

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

      (Posting this, because the last post was reaped)