Inserting an empty row
oracle, oracle11g
Solution
Basically, in order to insert a row where values for all columns are `NULL` except primary
key column's value you could execute a simple `insert` statement:
insert into your_table(PK_col_name)
values(1); -- 1 for instance or null
The before insert trigger, which is responsible for populating primary key column will
override the value in the `values` clause of the `insert` statement leaving you with an
empty record except `PK` value.
Problem
This is so simple it has probably already been asked, but I couldn't find it (if that's the case I'm sorry for asking). I would like to insert an empty row on a table so I can pick up its ID (primary key, generated by an insert trigger) through an ExecuteScalar. Data is added to it at a later time in my code. My question is this: is there a specific insert syntax to create an empty record? or must I go with the regular insert syntax such as "INSERT INTO table (list all the columns) values (null for every column)"? Thanks for the answer. UPDATE: In Oracle, ExecuteScalar on INSERT only returns 0. The final answer is a combination of what was posted below. First you need to declare a parameter, and pick up it up with RETURNING. ``` INSERT INTO TABLENAME (ID) VALUES (DEFAULT) RETURNING ID INTO :parameterName ``` Check this out link for more info.