in reply to Problem with insert using DBI

It seems like you may have an error in your SQL statement. I believe the proper syntax is either:
INSERT INTO table VALUES (value1, value2, ...)
if you want to list the values in order, or:
INSERT INTO table SET column1=value1, column2=value2, ...
if you want to specify the columns individually.

General suggestions for debugging DB code: print your SQL statement so you can visually verify it; include $DBI::errstr in your "or die"; tweak your SQL statements at the DB console until they behave the way you suggest.

Good luck.

Update: As VSarkiss points out below, listing the column names explicitly is always a good idea. Using SET in INSERT may be behavior that's specific to MySQL, so the general-purpose format that rdfield spells out is probably a better choice.

Replies are listed 'Best First'.
Re: Re: It won't insert
by rdfield (Priest) on Mar 20, 2002 at 10:25 UTC
    INSERT INTO table SET column1=value1, column2=value2, ...

    depends on the RDBMS: for instance, Oracle's Insert statement is:

    INSERT INTO table (column1,column2,...) VALUES (value1,value2,...)

    rdfield

Re: Re: It won't insert
by VSarkiss (Monsignor) on Mar 20, 2002 at 17:04 UTC

    Sorry, but this is very poor advice. It's always better to list the columns in an insert statement rather than depending on column order in the table. It costs you nothing (other than typing ;-), clarifies your intent, and protects you against future changes to the table. The syntax has been standard since at least SQL-89, so any self-respecting RDBMS will support it.

    I think your other example is confusing UPDATE statements with INSERT statements. It's UPDATE table SET col = val, ...There is no SET clause in an INSERT statement in any dialect of SQL I know.