Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. create or replace procedure upsert_t23
  2. ( p_id in t23.id%type
  3. , p_name in t23.name%type )
  4. is
  5. cursor c is
  6. select null
  7. from t23
  8. where id = p_id;
  9. dummy varchar2(1);
  10. begin
  11. open c;
  12. fetch c into dummy;
  13. if c%notfound then
  14. insert into t23
  15. values (p_id, p_name);
  16. else
  17. update t23
  18. set name = p_name
  19. where id = p_id;
  20. end if;
  21. end;
  22.  
  23. SSN1> exec upsert_t23(100, 'FOX IN SOCKS')
  24.  
  25. SSN2> exec upsert_t23(100, 'MR KNOX')
  26.  
  27. ...
  28. lock table t23 in row shared mode nowait;
  29. open c;
  30. ...
  31.  
  32. try {
  33. // MERGE
  34. }
  35. catch (dup_val_on_index) {
  36. // UPDATE
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement