/sql/Function/reports_set_copy_number.sql

http://cupsfilter.googlecode.com/ · SQL · 25 lines · 20 code · 3 blank · 2 comment · 2 complexity · 97d28e82718a230ea030d7e9ce33490f MD5 · raw file

  1. --DROP FUNCTION reports_set_copy_number(integer,integer);
  2. CREATE OR REPLACE FUNCTION reports_set_copy_number(integer,integer)
  3. RETURNS INTEGER AS
  4. $BODY$
  5. DECLARE
  6. find_id INTEGER;
  7. rep_id ALIAS for $1;
  8. field_val ALIAS for $2;
  9. BEGIN
  10. find_id = (SELECT id FROM reports WHERE id = rep_id);
  11. IF (find_id IS NULL) THEN
  12. INSERT INTO debug_log (inf_str) VALUES ('?????? ??????? ??????. ? ??????? reports ?? ?????????? ?????? ? ??????????? ?? ??????? cups_data_log ?????? N='||rep_id);
  13. RETURN 0;
  14. END IF;
  15. -- ???? ???????? copy number)
  16. UPDATE reports SET copy_number = field_val WHERE reports.id = find_id;
  17. RETURN 1;
  18. END;
  19. $BODY$
  20. LANGUAGE 'plpgsql' VOLATILE
  21. COST 100;
  22. ALTER FUNCTION reports_set_copy_number(integer,integer) OWNER TO postgres;