thefid has asked for the wisdom of the Perl Monks concerning the following question:
I have tried leaving the field out, in which I get the "Too few parameters" error. I've tried an blank variable, which gives me a "Data Type mismatch" error. Also, I've tried the number 0, which will write a record where the sequential key is 0, but of course if I try to write another record, I get a duplicate key error. The table looks like:
Here's my test code:order <--- table name ------- seq <--- primary key, autonumber item desc qty date_time user
Has anyone had experience in doing this? Any help will be much appreciated. thanks.# Make Database connection $db = new Win32::ODBC("DSN=$DATA_SOURCE_NAME; UID=$USER_ID;PWD=$PASSWORD;") or die Win32::ODBC::Error(); # Test Variables $new_item = "Test"; $new_desc = "Test description"; $new_qty = 2099; $new_user = "TESTUSER"; # get current time $now_time = gmtime; $new_seq = 0; # Insert row into database if ($db->Sql("INSERT INTO order VALUES ($new_seq,'$new_item', '$new_desc', $new_qty,'$now +_time','$new_user')" )) { # Print out any ODBC/SQL error print $db->Error(); } # Close the database $db->Close();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::ODBC insert question
by dws (Chancellor) on Mar 22, 2001 at 03:10 UTC | |
|
(crazyinsomniac) Re: Win32::ODBC insert question
by crazyinsomniac (Prior) on Mar 22, 2001 at 01:35 UTC |