Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as SQL by registered user Ketra ( 17 years ago )
CREATE OR REPLACE FUNCTION get_human_id_func(firstname character, surname character, patname character)
  RETURNS integer AS
$BODY$ 
DECLARE h_id human_tab.human_id%TYPE;
BEGIN
SELECT human_tab.human_id INTO h_id 
FROM human_tab
WHERE human_tab.firstname = $1 AND
  human_tab.surname = $2 AND
  human_tab.patronymicname = $3;
RETURN h_id;
END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION get_human_id_func(character, character, character) OWNER TO pgsql;

 
CREATE OR REPLACE RULE "_DELETE" AS
ON DELETE TO human_view DO INSTEAD 
    (
 DELETE FROM host_tab WHERE host_tab.human_id = get_human_id_func( old.firstname, old.surname,  old.patname);
 DELETE FROM human_tab WHERE human_tab.human_id = get_human_id_func( old.firstname, old.surname,  old.patname);
    );

 

Revise this Paste

Children: 9141
Your Name: Code Language: