View difference between Paste ID: zp5w3L0b and q8VqB3GL
SHOW: | | - or go back to the newest paste.
1
-- Procedure de test_retrieve_items
2
CREATE OR REPLACE FUNCTION get_all_test() RETURNS SETOF test_pepe AS 'select * from test_pepe;' language 'sql';
3
4
-- Procedure de test_add_item
5
6-
CREATE OR REPLACE FUNCTION layers.test_add_item (p_url IN varchar, p_origin IN varchar) RETURNS boolean
6+
CREATE OR REPLACE FUNCTION test_add_item (p_url IN varchar, p_origin IN varchar) RETURNS boolean
7
	AS $BODY$
8
begin
9
	insert into test_pepe (url,origin)
10
		values (p_url,p_origin);
11
12
	return true;
13
	
14
exception 
15
	WHEN unique_violation THEN
16
		RAISE unique_violation USING MESSAGE = 'TABLE test_pepe: DUPLICATED VALUE "' || p_url || '" ON FIELD NAMED "url"';
17
18
		return false;
19
		
20
	WHEN others THEN
21
		RAISE EXCEPTION 'OTHER EXECP INSERTING VALUES (%, %)', p_url, p_origin USING HINT = 'Please check the values';
22
		return false;
23
end;
24
$BODY$
25
	LANGUAGE plpgsql;