PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/sql/Function/reports_set_inv_number.sql

http://cupsfilter.googlecode.com/
SQL | 26 lines | 20 code | 3 blank | 3 comment | 2 complexity | fb54912cbd5dbd0a4a41fbddbb3b472a MD5 | raw file
 1--DROP FUNCTION reports_set_inv_number (integer,integer);
 2CREATE OR REPLACE FUNCTION reports_set_inv_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	-- full check 
12	find_id = (SELECT id FROM reports WHERE id = rep_id);
13	IF (find_id IS NULL) THEN
14		INSERT INTO debug_log (inf_str) VALUES ('?????? ??????? ??????. ? ??????? reports ?? ?????????? ?????? ? ??????????? ??  ??????? cups_data_log ?????? N='||rep_id);
15		RETURN 0;
16	END IF;
17
18	-- ???? ???????? punkt
19	UPDATE  reports SET inv_number = field_val WHERE reports.id = find_id;
20	
21	RETURN 1;
22    END;
23$BODY$
24  LANGUAGE 'plpgsql' VOLATILE
25  COST 100;
26ALTER FUNCTION reports_set_inv_number (integer,integer)OWNER TO postgres;