
big_v
New User
Aug 1, 2002, 9:04 AM
Post #1 of 8
(18294 views)
|
Inserting a NULL value
|
Can't Post
|
|
Hi I am trying to insert a NULL value into a table. Details below.....
my $stha = $dbh->prepare("select * from mytable"); $stha->execute; while ($arrayref = $stha->fetchrow_arrayref) { $sthb = $dbh->prepare("INSERT INTO $arrayref->[30] VALUES ('$arrayref->[0]','$arrayref->[1]','$arrayref->[2]',$arrayref->[3],'$arrayref->[4]','$arrayref->[5]','$arrayref->[6]','$arrayref->[7]','$arrayref->[8]','$arrayref->[9]','$arrayref->[10]','$arrayref->[11]',$arrayref->[12],$arrayref->[13],$arrayref->[14],$arrayref->[15],$arrayref->[16],$arrayref->[17],$arrayref->[18],$arrayref->[19],$arrayref->[20],$arrayref->[21],'$arrayref->[22]','$arrayref->[23]','$arrayref->[24]','$arrayref->[25]',\"\",\"\",'$arrayref->[28]',$arrayref->[29],'$arrayref->[30]','$arrayref->[31]','$arrayref->[32]','$arrayref->[33]','$arrayref->[34]','$arrayref->[35]','$arrayref->[36]','$arrayref->[37]','$arrayref->[38]'"); } $sthb->execute or die "can't execute the insert: $sthb->errstr\n"; As you can see, there are a large number of fields returned from the fetchrow_arrayref. From a previous mysqldump, $arrayref->[26] and $arrayref->[27] are both NULL in value. However, after the fetchrow_arrayref, arrayref->[26] and $arrayref->[27] return '' (an empty string). If I try to insert this value a new table, I get an error message such as ...... You have an error in your SQL syntax near '' at line 1 at ./sort_mysql line 52. can't execute the insert: DBI::st=HASH(0x820b208) Line 52 being the $sthb->execute Any ideas Thanks in advance
|