SHARE
TWEET

Untitled

a guest Dec 13th, 2016 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT fieldA, fieldB, fielbC
  2. INTO temp_table
  3. FROM dblink('dbname=dbname port=5432 host=a.b.c.d user=user password=pw',
  4. E'SELECT fieldA, fieldB, fieldC FROM data_table')
  5. AS temp_table(fieldA integer, fieldB integer, fieldC integer);
  6.    
  7. CREATE OR REPLACE FUNCTION archive() RETURNS trigger AS $$
  8. DECLARE
  9. BEGIN
  10.  
  11.     execute
  12.     '
  13. SELECT fieldA, fieldB, fielbC
  14. INTO temp_table
  15. FROM dblink(''dbname=dbname port=5432 host=a.b.c.d user=user password=pw'',
  16. E''SELECT fieldA, fieldB, fieldC FROM data_table'')
  17. AS temp_table(fieldA integer, fieldB integer, fieldC integer);
  18.     ';
  19.  
  20.     return new;
  21. END;
  22. $$ LANGUAGE plpgsql;
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
 
Top