No such thing as a small change | |
PerlMonks |
DBI: data types, binding and insertionsby Sandy (Curate) |
on Dec 13, 2008 at 00:47 UTC ( [id://730087]=perlquestion: print w/replies, xml ) | Need Help?? |
Sandy has asked for the wisdom of the Perl Monks concerning the following question:
I am trying, for the very first time, to insert a bunch of data into a database. I have read DBI over and over, but I cannot seem to resolve my problem. In DBI it states clearly that one cannot change the data type of bound variables
The data type for a bind variable cannot be changed after the first bind_col call. In fact the whole \%attr parameter is 'sticky' in the sense that a driver only needs to consider the \%attr parameter for the first call for a given $sth and column.But I have string data that is sometimes empty, and when I try to insert that row, the database complains. I have tried many different combinations, but the only thing that seems to work is if I replace the empty string with a string of at least one character. Sample code is shown below (most of my error checking has been removed to simplify the code) I have also tried inserting $sth->finish() in-between each attempt, to no avail. Next and Another will be inserted into the db, but nothing else will. I am using ODBC to connect to an Oracle database using "DataDirect" wire protocol. One of the error messages is (added /n to make it easier to read):
Notes: If I comment out the insertions of Next and Another, then the other rows will be inserted (i.e. there is no restriction to empty or null values for the 4th parameter) So, my question is... how do I make an empty string look to be the same datatype as a non-empty string? Sandy
Back to
Seekers of Perl Wisdom
|
|