K
Kevin Schneider
I am trying to insert a new row into a table in Oracle. The table
generates the ID during the insert through the use of a trigger.
How can I pull back the generated ID when I do the insert with the
following InsertCommand?
OracleInsertCommand1.CommandText = "INSERT INTO WIDGETS(WIDGETID,
NAME) VALUES WIDGETID, :NAME)"
OracleInsertCommand1.Connection = OracleConnection1
OracleInsertCommand1.Parameters.Add(New OracleParameter(":NAME",
OracleType.VarChar, 50, "NAME"))
I figured I needed to add an Output parameter so I added the something
like the following:
OracleInsertCommand1.Parameters.Add(New
OracleParameter(":WidgetIDOUT", OracleType.Number, 0,
ParameterDirection.Output, False, CType(38, Byte), CType(0, Byte),
"WIDGETID", DataRowVersion.Current, Nothing))
But when I try to do the insert, I get the Oracle error "ORA-01036:
illegal variable name/number".
I ran across the Oracle clause "RETURNING" for the INSERT command, is
this the place to use it?
generates the ID during the insert through the use of a trigger.
How can I pull back the generated ID when I do the insert with the
following InsertCommand?
OracleInsertCommand1.CommandText = "INSERT INTO WIDGETS(WIDGETID,
NAME) VALUES WIDGETID, :NAME)"
OracleInsertCommand1.Connection = OracleConnection1
OracleInsertCommand1.Parameters.Add(New OracleParameter(":NAME",
OracleType.VarChar, 50, "NAME"))
I figured I needed to add an Output parameter so I added the something
like the following:
OracleInsertCommand1.Parameters.Add(New
OracleParameter(":WidgetIDOUT", OracleType.Number, 0,
ParameterDirection.Output, False, CType(38, Byte), CType(0, Byte),
"WIDGETID", DataRowVersion.Current, Nothing))
But when I try to do the insert, I get the Oracle error "ORA-01036:
illegal variable name/number".
I ran across the Oracle clause "RETURNING" for the INSERT command, is
this the place to use it?