Currently I have a table with this structure:
CREATE TABLE "DUMMY_SCHEMA"."NAMES"
(
"ID" NUMBER(10,0) GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1 CACHE 20) NOT NULL
, "NAME" NVARCHAR2(1024) NOT NULL
, CONSTRAINT "NAMES_PK" PRIMARY KEY ("ID")
);
In SQL Server I only need to do following to get the Id of the inserted row.
INSERT INTO [NAMES]([NAME])VALUES('Random'); SELECT SCOPE_IDENTITY() Id
What would be the equivalent for Oracle 12c?
The equivalent is
INSERT INTO dummy_schema.names (name) VALUES ('Random')
RETURNING id INTO :myvalue;
The mechanism how to pick up the returned ID depends on the host language (Java, PL/SQL, SQL*Plus etc).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With