Guest User

Untitled

a guest
Jun 20th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. CREATE TABLE master.parties
  2. (
  3. party_key serial NOT NULL,
  4. name text,
  5. date_of_birth date,
  6. phone text,
  7. CONSTRAINT "PK_master_parties" PRIMARY KEY (party_key)
  8. )
  9.  
  10. CREATE TABLE corporate.parties
  11. (
  12. corp_key integer,
  13. corp_role text
  14. ) INHERITS (master.parties)
  15.  
  16. WITH deleted AS (
  17. DELETE FROM ONLY master.parties
  18. WHERE party_key = 1
  19. returning *
  20. )
  21. INSERT INTO corporate.parties (name, date_of_birth, phone, corp_key, corp_role)
  22. SELECT name, date_of_birth, phone, 2, 'President'
  23. from deleted;
Add Comment
Please, Sign In to add comment