Hi all
I want to insert a record to a table in oracle and read its ID just after inserting it.
I don't want to lose my record while so many records might be inserted at the time.
How can I do that?
Thanks a lot
Make a counterpart of original dataset, then using EXCEPT operation to see what record you have inserted.
data one;set sashelp.class;run; data two;set sashelp.class;run; proc sql; insert into one values('Patrick','M',30,52.2,89.4); select * from one except select * from two; quit;
Ksharp
Dear Ksharp
I read the values from table 'three' and insert it to 'one', how can I keep the rsult of (select *... ) in a table? It seems that it doesn't understand the code.
my code is:
data three;
input name $ sex$ age@@ height@@ weight@@;
cards;
Patrick M 30 52.2 89.4
;
run;
proc sql;
insert into one (name, sex, age, height, weight)
select name, sex, age, height, weight
from three;
select * from one
except
select * from two;
quit;
run;
OK. Easy.
data one; set sashelp.class; run; data two; set sashelp.class;run; data three; input name $ sex$ age height weight; cards; Patrick M 30 52.2 89.4 Peter M 40 54.3 100.2 ; run; proc sql; insert into one select * from three; create table want as select * from one except select * from two; quit;
Ksharp
another question:
Does this code guarantee that we read the inserted record?
I mean if another data inserted from another procedure while our proc sql is running, does it guarantee that the result is our record?
this procedure lock the table while runing or not?
Just as Tom said, I think you need some help from Oracle Administrator .
If you are familiar with Oracle ,why not do it in Oracle?
Ksharp
Why do you need to know the ID number generated by the Oracle database?
If you are not competing against other proceses then just query the database to find the record you just inserted. Otherwise if you really need to get the number that Oracle generated you might need to trigger a stored procedure in Oracle that would insert the record and return the new ID as the result.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.