Creation
-- Delete a feedfile
CREATE OR REPLACE FUNCTION delete_feedfile(integer)
RETURNS void AS
'
DELETE FROM feedfile
WHERE id=$1;
'
LANGUAGE SQL
;
-- Example
-- SELECT delete_feedfile(36);
-- Delete a range of feedfiles
CREATE OR REPLACE FUNCTION delete_feedfiles(integer, integer)
RETURNS void AS
'
BEGIN
FOR i IN $1..$2 LOOP
PERFORM delete_feedfile(i);
END LOOP;
END;
'
LANGUAGE plpgsql
;
-- Example
-- SELECT delete_feedfiles(1,10);
-- Delete a feed
CREATE OR REPLACE FUNCTION delete_feed(integer)
RETURNS void AS
'
DECLARE
row record;
BEGIN
DELETE FROM feedsthist WHERE feedid=$1;
FOR row in (SELECT id FROM feedfile WHERE feedid=$1) LOOP
PERFORM delete_feedfile(row.id);
END LOOP;
DELETE FROM feed WHERE id=$1;
END;
'
LANGUAGE plpgsql
;
-- SELECT delete_feed(3);
List
database-devel=# \df+ delete_feedfile