Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create or replace procedure upsert_t23
- ( p_id in t23.id%type
- , p_name in t23.name%type )
- is
- cursor c is
- select null
- from t23
- where id = p_id;
- dummy varchar2(1);
- begin
- open c;
- fetch c into dummy;
- if c%notfound then
- insert into t23
- values (p_id, p_name);
- else
- update t23
- set name = p_name
- where id = p_id;
- end if;
- end;
- SSN1> exec upsert_t23(100, 'FOX IN SOCKS')
- SSN2> exec upsert_t23(100, 'MR KNOX')
- ...
- lock table t23 in row shared mode nowait;
- open c;
- ...
- try {
- // MERGE
- }
- catch (dup_val_on_index) {
- // UPDATE
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement