Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Invalid Precision error

by ikegami (Patriarch)
on Apr 28, 2010 at 05:18 UTC ( [id://837224]=note: print w/replies, xml ) Need Help??


in reply to Invalid Precision error

Three things I've spotted
  • $data = "'".$data_ref."'"; invalidates your dates for sure, probably everything else too. Instead of passing a date, you're passing an SQL string literal of a date. Just pass the date. That's the whole point of placeholders. Well ok, one major point of placeholders.

  • You call keys %hdr_field_vars twice, expecting the keys to be returned in the same order both times. I think it actually will do so in this very specific program, but it's a very fragile assumption. You'd do well to avoid that assumption. (Save the result of keys %hdr_field_vars into an array, and iterate over the array.)

  • DBI might be guessing the type of your data incorrectly. (number instead of string, string instead of number) You might need to tell it the proper type (via bind_param).

Replies are listed 'Best First'.
Re^2: Invalid Precision error
by Bheema_Tyco (Novice) on Apr 28, 2010 at 05:57 UTC

    i did this and executed then even though the same problem

    <code> my $counter = 1; foreach my $key (keys %hdr_field_vars) { my $data_ref = $hdr_field_vars{$key}[0]; # my $form=$hdr_field_vars{$key}1; my $data; # if(($form=~/^V1$/ || $form=~/^V4$/ || $form=~/^V2$/ || $form=~/^V15$/) && defined($data_ref)){ # if($data_ref ne 'NULL'){ # $data = "'".$data_ref."'"; # } # else # { $data = $data_ref; # } # } # else{ # $data = $data_ref; # } print $JBM $data."\n"; # use Data::Dumper; # print $JBM "<--------------------"; # print $JBM Dumper($data); # print $JBM "-------------------->\n"; $sth_header->bind_param( $counter, $data); $counter++; }

    ok about second point i know that, the hash will return the values in random order

    for date its giving error

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-24 19:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found