Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Date Problem

by Anonymous Monk
on Apr 26, 2010 at 09:35 UTC ( #836867=note: print w/ replies, xml ) Need Help??


in reply to Re: Date Problem
in thread Date Problem

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


Comment on Re^2: Date Problem
Download Code
Re^3: Date Problem
by moritz (Cardinal) on Apr 26, 2010 at 10:37 UTC
    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.

Re^3: Date Problem
by nagalenoj (Friar) on Apr 26, 2010 at 12:02 UTC
    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)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://836867]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2015-07-07 02:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (86 votes), past polls