Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 22nd, 2012  |  syntax: None  |  size: 0.36 KB  |  views: 14  |  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 FUNCTION INCREMENT()
  2. RETURNS INT
  3. BEGIN
  4. DECLARE newVal;
  5. UPDATE table_x SET currentVal=currentVal+1;
  6. SELECT currentVal INTO newVal FROM table_x;
  7. RETURN newVal;
  8. END;
  9.        
  10. CREATE FUNCTION INCREMENT()
  11. RETURNS INT
  12. BEGIN
  13. DECLARE newVal;
  14. Begin tran
  15. UPDATE table_x SET currentVal=currentVal+1;
  16. SELECT currentVal INTO newVal FROM table_x;
  17. Commit tran
  18. RETURN newVal;
  19. END;