PageRenderTime 45ms CodeModel.GetById 29ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 1ms

/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);
 2CREATE 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    
10    BEGIN
11	find_id = (SELECT id FROM reports WHERE id = rep_id);
12	IF (find_id IS NULL) THEN
13		INSERT INTO debug_log (inf_str) VALUES ('?????? ??????? ??????. ? ??????? reports ?? ?????????? ?????? ? ??????????? ??  ??????? cups_data_log ?????? N='||rep_id);
14		RETURN 0;
15	END IF;
16	
17	-- ???? ???????? copy number)
18	UPDATE  reports SET copy_number = field_val WHERE reports.id = find_id;
19	
20	RETURN 1;
21    END;
22$BODY$
23  LANGUAGE 'plpgsql' VOLATILE
24  COST 100;
25ALTER FUNCTION reports_set_copy_number(integer,integer) OWNER TO postgres;