adding fields to allow for multiple playlists scheduled in a show
This commit is contained in:
parent
daf37fa548
commit
9854834b26
7 changed files with 37 additions and 7 deletions
|
@ -21,3 +21,27 @@ CREATE FUNCTION calculate_position() RETURNS trigger AS
|
|||
|
||||
CREATE TRIGGER calculate_position AFTER INSERT OR DELETE ON cc_playlistcontents
|
||||
FOR EACH ROW EXECUTE PROCEDURE calculate_position();
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
--show_content()
|
||||
----------------------------------------------------------------------------------
|
||||
DROP FUNCTION show_content() CASCADE;
|
||||
|
||||
CREATE FUNCTION show_content() RETURNS trigger AS
|
||||
'
|
||||
BEGIN
|
||||
IF(TG_OP=''INSERT'') THEN
|
||||
UPDATE cc_show_schedule SET position = (position + 1)
|
||||
WHERE (id = new.id AND position >= new.position AND id != new.id);
|
||||
END IF;
|
||||
IF(TG_OP=''DELETE'') THEN
|
||||
UPDATE cc_show_schedule SET position = (position - 1)
|
||||
WHERE (id = old.id AND position > old.position);
|
||||
END IF;
|
||||
RETURN NULL;
|
||||
END;
|
||||
'
|
||||
LANGUAGE 'plpgsql';
|
||||
|
||||
CREATE TRIGGER show_content AFTER INSERT OR DELETE ON cc_show_schedule
|
||||
FOR EACH ROW EXECUTE PROCEDURE show_content();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue