Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Procedure de test_retrieve_items
- CREATE OR REPLACE FUNCTION get_all_test() RETURNS SETOF test_pepe AS 'select * from test_pepe;' language 'sql';
- -- Procedure de test_add_item
- CREATE OR REPLACE FUNCTION test_add_item (p_url IN VARCHAR, p_origin IN VARCHAR) RETURNS BOOLEAN
- AS $BODY$
- BEGIN
- INSERT INTO test_pepe (url,origin)
- VALUES (p_url,p_origin);
- RETURN TRUE;
- EXCEPTION
- WHEN unique_violation THEN
- RAISE unique_violation USING MESSAGE = 'TABLE test_pepe: DUPLICATED VALUE "' || p_url || '" ON FIELD NAMED "url"';
- RETURN FALSE;
- WHEN OTHERS THEN
- RAISE EXCEPTION 'OTHER EXECP INSERTING VALUES (%, %)', p_url, p_origin USING HINT = 'Please check the values';
- RETURN FALSE;
- END;
- $BODY$
- LANGUAGE plpgsql;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement