daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. create table t1 (id number primary key, memo varchar2 (4000));
  2. create sequence seqt1 nocache;
  3.    
  4. declare
  5.     r t1%rowtype;
  6. begin
  7.     r.id := seqt1.nextval;
  8.     r.memo := 'first row';
  9.     insert into t1 values r;
  10. end;
  11. /
  12.    
  13. ID MEMO      
  14. ---------- ----------
  15.          1 first row
  16.    
  17. drop table t1;    
  18. create table t1 (id number generated always as identity primary key, memo varchar2 (4000));
  19.    
  20. create table t1 (id number generated always as identity primary key, memo varchar2 (4000))
  21. ;
  22. create or replace view viewt1 (id invisible, memo) as select * from t1
  23. ;
  24. <<my>> declare
  25.     r viewt1%rowtype;  
  26.     id number;
  27. begin
  28.     r.memo := 'first row';
  29.     insert into viewt1 values r
  30.     returning id into my.id
  31.     ;
  32.     dbms_output.put_line ('inserted '||sql%rowcount||' row(s) id='||id);  
  33. end;
  34. /
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand