Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. CREATE FUNCTION public.addupdateemployee(IN employeeid bigint, IN employeetitle text, IN employeeaddress text)
  2. RETURNS bigint
  3. LANGUAGE 'plpgsql'
  4.  
  5. AS $BODY$
  6. BEGIN
  7. DECLARE affectedrecordid bigint = 0
  8. IF employeeid = 0 THEN
  9. INSERT INTO employeemaster(title, address)
  10. values(employeetitle, employeeaddress)
  11. RETURNING id INTO affectedrecordid;
  12. RETURN affectedrecordid;
  13. ELSE
  14. UPDATE employeemaster
  15. SET title = employeetitle,
  16. address = employeeaddress
  17. WHERE id = employeeid
  18. RETURN employeeid;
  19. END IF
  20. END
  21. $BODY$;
  22.  
  23. ERROR: syntax error at or near "IF"
  24. LINE 8: IF employeeid = 0 THEN
  25. ^
  26. SQL state: 42601
  27. Character: 218
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement