From e30ee019294e2abbbd3644b73e4327ae17df4392 Mon Sep 17 00:00:00 2001 From: ckonstanski Date: Mon, 27 May 2024 14:52:07 -0600 Subject: gallery --- sql/functions/general.update_gallery.sql | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 sql/functions/general.update_gallery.sql (limited to 'sql/functions/general.update_gallery.sql') diff --git a/sql/functions/general.update_gallery.sql b/sql/functions/general.update_gallery.sql new file mode 100644 index 0000000..e8532db --- /dev/null +++ b/sql/functions/general.update_gallery.sql @@ -0,0 +1,43 @@ +drop function general.update_gallery ( + p_id bigint, + p_description text, + p_filename character varying, + p_mime_type character varying, + p_hex text +); + +create or replace function general.update_gallery ( + p_id bigint, + p_description text, + p_filename character varying, + p_mime_type character varying, + p_hex text +) +returns bigint +as $$ +declare + l_id bigint; +begin + select g.id into l_id + from general.gallery g + where g.id = p_id; + + if(l_id is not null) then + update general.gallery + set description = p_description, + filename = p_filename, + mime_type = p_mime_type, + content = decode(p_hex, 'hex'), + modified = now() + where id = p_id; + + select g.id into l_id + from general.gallery g + where g.id = p_id; + + return l_id; + else + return null; + end if; +end; +$$ language plpgsql; -- cgit v1.3