hallikpapa has asked for the wisdom of the Perl Monks concerning the following question:
And here is the execute$SQL = "INSERT INTO iCDRSbw (rec_num,src_file,src_host,init_status,cdr +_day,last_modified,city,state,cname,vname, npa,nxx,ocn,lata,lata_name,pdd,zone_id,cdrs_seq,file_seq,g +c_id ) VALUES (?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?)"; my $database_username = "USER"; my $database_password = "PASS"; my $msdsn = q/dbi:ODBC:DRIVER={SQL Server};Server=10.0.0.5;attr=value/ +; my $dbh = DBI->connect( $msdsn, $database_username, $database_password + ) or die "ERROR"; $dbh->do("use db_name") or log_die("$DBI::errstr");
$f20 and $f04 are dates, everything else in single quotes are char fields. Otherwise they are int fields. All variables are populated, but just in case I set each field to allow NULL = true It gives me this error from the Serverunless ( $sth->execute($rec_num, '$src_cdr_file', '$host','$init_status +', '$f[20]', '$f[04]', '$city', '$state', '$cname', '$vname', $npa, $nxx, '$ocn', $lata, $lata_name, $pdd, $f[0], $f[1], $f[2], '$f[3]' ) ) { $now = localtime(time); print "Error inserting: $DBI::errstr\n" if ($LOGERR); }
This statement works fine manually, so I am obviously not handling the variables correctly.Error inserting: [Microsoft][ODBC SQL Server Driver]Invalid character +value for cast specification (SQL-22018)(DBD: st_execute/SQLExecute e +rr=-1)
INSERT INTO iCDRSbw (rec_num,src_file,src_host,init_status,cdr_day,las +t_modified,city,state,cname,vname, npa,nxx,ocn,lata,lata_name,pdd,zone_id,cdrs_seq,file_seq,g +c_id ) VALUES (1,'icdr.5_5_5B.0.1.200712170000.052964.0','127.0.0.1','Unpro +cessed','2007-12-17 00:00:47', '2007-12-17 00:00:47','NA','NA',' ',' ', 999,999,' ',1,1, 1,1,1,1,'AAAAC0dlvAgiIAABC7Przw.7591990');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: What is wrong with this mSQL insert?
by kyle (Abbot) on Feb 26, 2008 at 21:41 UTC | |
by hallikpapa (Scribe) on Feb 26, 2008 at 22:11 UTC | |
by kyle (Abbot) on Feb 26, 2008 at 22:24 UTC | |
by chrism01 (Friar) on Feb 27, 2008 at 01:11 UTC | |
|
Re: What is wrong with this mSQL insert?
by graff (Chancellor) on Feb 27, 2008 at 03:15 UTC |