On 7/20/11 Wed  Jul 20, 2011  9:04 AM, "Mohan L" <l.mohan...@gmail.com>
scribbled:

> On Wed, Jul 20, 2011 at 9:23 PM, shawn wilson <ag4ve...@gmail.com> wrote:
> 
>> On Wed, Jul 20, 2011 at 10:41, Mohan L <l.mohan...@gmail.com> wrote:
>> 
>>> 
>>> DBD::mysql::st execute failed: Column 'open' cannot be null at
>>> ./demo.plline 104, <CSV> line 30.
>>> DBD::mysql::st execute failed: Column 'open' cannot be null at
>>> ./demo.plline 104, <CSV> line 30.
>>> DBD::mysql::st execute failed: Column 'open' cannot be null at
>>> ./demo.plline 104, <CSV> line 30.
>>> DBD::mysql::st execute failed: Column 'open' cannot be null at
>>> ./demo.plline 104, <CSV> line 30.
>>> 
>>> I am hanging on this issue.  Any help will be really appreciated.
>>> 
>> 
>> not sure what your table looks like. however, if you want to be able
>> to not have any data in a column, you need to allow the column to be
>> null. you should also do something like:
>> $data = $column //= "";
>> 
> 
> for my $datum (@dbdata)
> {
>    print "$datum\n";
> }
> 
> Output :
> 
> east,0,0,2,4,0,0,0,6
> north,0,0,7,3,0,0,0,10
> south,3,0,1,3,0,0,0,7
> west,7,0,0,0,0,0,0,7

If that is really the output from the print statement shown above, then you
don't have a rows of column data in your @dbdata array elements, you have an
array of scalar string values that are the concatenated values of the
desired column values joined with commas.

Use the Data::Dumper module to see what is really contained within your data
array:

use Data::Dumper;
...
print Dumper(\@dbdata);


> 
> But the below code does not work :
> 
> for my $datum (@dbdata) {
>     $query_handle->execute(@$
> datum);
> }

That assumes that the elements of @dbdata are references to arrays. Printing
the array using the Data::Dumper module will tell you if that is so.

If the elements are really 'east,0,0,2,4,0,0,0,6' and the like, then you are
probably trying to store that string into the first column and nothing into
the subsequent columns. That might explain why you are getting "column
cannot be null" error messages.

You could split the scalar into columns:

my @row = split(/,/,$dbdata);

but you should probably go back and figure out why @dbdata contains the data
that it does. 

If you want more help, please post a short, complete program that
demonstrates the problem you are having, and one that other people can
execute on their own systems.

Thanks.



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to