CREATE OR REPLACE FUNCTION core.fx_artist_del(integer, timestamp with time zone)
RETURNS integer AS
$BODY$
--
-- Удаление исполнителя
--
DECLARE
r core.artists_tracks%rowtype;
k core.artists_clips%rowtype;
save_artist_deleted timestamp;
BEGIN
SELECT artist_deleted INTO save_artist_deleted
FROM core.artists WHERE obj_id=$1;
IF NOT save_artist_deleted IS NULL THEN
RETURN 0;
END IF;
FOR r IN SELECT core.artists_tracks.* FROM core.artists_tracks
INNER JOIN core.tracks ON at_track_id=core.tracks.obj_id
WHERE track_deleted IS NULL AND at_artist_id=$1
LOOP
PERFORM core.fx_track_del(r.at_track_id,$2);
END LOOP;
UPDATE core.artists SET artist_deleted=$2 WHERE obj_id=$1;
RETURN 1;
END
--
$BODY$
LANGUAGE 'plpgsql' VOLATILE SECURITY DEFINER
COST 100;
ALTER FUNCTION core.fx_artist_del(integer, timestamp with time zone) OWNER TO sk4_admin;
GRANT EXECUTE ON FUNCTION core.fx_artist_del(integer, timestamp with time zone) TO sk4_admin;
GRANT EXECUTE ON FUNCTION core.fx_artist_del(integer, timestamp with time zone) TO public;
SQL Справочник v0.05 © 2007-2025 Igor Salnikov aka SunDoctor