This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Function behaviour

By: a guest on Apr 26th, 2012  |  syntax: SQL  |  size: 0.50 KB  |  views: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. CREATE temp TABLE msl09(c1 text, c2 text);
  2. INSERT INTO msl09 VALUES ('123', '321');
  3. INSERT INTO msl09 VALUES ('abcd', '321');
  4. INSERT INTO msl09 VALUES ('abcdw', '321');
  5. INSERT INTO msl09 VALUES('234', '4a66');
  6. INSERT INTO msl09 VALUES('234', '466');
  7.  
  8. CREATE OR REPLACE FUNCTION test() RETURNS INTEGER AS $$
  9. DELETE FROM msl09 WHERE c2 = (SELECT c2 FROM msl09 WHERE c1 = '123');
  10. DELETE FROM msl09 WHERE c1 = (SELECT c2 FROM msl09);
  11. SELECT 1;
  12. $$ LANGUAGE SQL;
  13.  
  14. SELECT test();
  15. SELECT * FROM msl09;
clone this paste RAW Paste Data