I have created a table with generated identity column .script below CREATE TABLE "TABLESAMPLE" ( "DESCRIPTION" VARCHAR2(2 BYTE), "TID" NUMBER(5,0) GENERATED ALWAYS AS IDENTITY MINVALUE 1 MAXVALUE 99 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE NOKEEP NOSCALE NOT NULL ENABLE ) SEGMENT CREATION DEFERRED
i am inserting data to the db from a remote database using dblink like below. Here when i return the id i get the below error on (RETURNING )
Insert into TABLESAMPLE@dblink1(DESCRIPTION) values('1') RETURNING tid INTO v_tid_return;
*Cause: RETURNING clause is currently not supported for object type
columns, LONG columns, remote tables, INSERT with subquery,
and INSTEAD OF Triggers.
I am using oracle sql developer to run the script. can you please help
As it says:
Table over a database link is a remote table.
Mikeis user accessed via database link:Back to
scott(it contains database link to usermike):Would a synonym in my own schema help? Unfortunately, not:
What to do? Nothing much, regarding the
returningclause. If you recreated the table so that the ID isn't generated always (i.e. you're allowed to insert your own values):Find which sequence is being used for the identity column:
Connected as
scott, create a synonym to the sequence and use it ininsertstatement:Insert:
[EDIT]
If you want to get sequence name used for identity column, query
[EDIT #2]
If you want to use sequence name in PL/SQL procedure, you'll need dynamic SQL. Apart from that,
currvalwon't work if sequence hasn't been initialized yet in this session:Therefore, use
nextval: