Yaerox has asked for the wisdom of the Perl Monks concerning the following question:
Now I copy this lines by doing an insert on a second database with the same table called DB-2 table test2:ID | SOMEVALUE -------------- 1 | NULL 2 | text 1 | NULL
The result is fine test2 looks like test table. BUT ... i get uninitialized errors when those undefined values (NULL) are used. I see two ways to solve the problem: 1) Use constants, so i handle all those possible undefs and I concat my string as insert-statement and doingwhile ( ( $id, $value ) = $hStatement->fetrow_array ) { $hStatement2->prepare( INSERT INTO test2 VALUES ( ?, ? ) ); $hStatement2->execute( $id, $value ); }
2) Run this part of the code in a block using "no warnings". I don't like both ways because method 1 needs alot of if-code and statements are proberly less optimized for the database. But suppressing warnings is even worse imo. So I'd like to ask if any of you guys know, how to solve this problem in a good programmers way.$hStatement2->prepare( $sSQL_Statement ); $hStatement2->execute( );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI - Insert NULL value into DB
by Corion (Patriarch) on Aug 24, 2016 at 10:26 UTC | |
by Yaerox (Scribe) on Aug 24, 2016 at 11:36 UTC | |
|
Re: DBI - Insert NULL value into DB
by hippo (Archbishop) on Aug 24, 2016 at 11:00 UTC | |
|
Re: DBI - Insert NULL value into DB
by GotToBTru (Prior) on Aug 24, 2016 at 13:09 UTC | |
by hippo (Archbishop) on Aug 24, 2016 at 14:07 UTC | |
by GotToBTru (Prior) on Aug 24, 2016 at 14:42 UTC |