
sqltemplates.insertFunc.sql Maven / Gradle / Ivy
--
-- Copyright (C) 2011-2015 Incapture Technologies LLC
--
-- This is an autogenerated license statement. When copyright notices appear below
-- this one that copyright supercedes this statement.
--
-- Unless required by applicable law or agreed to in writing, software is distributed
-- on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
-- or implied.
--
-- Unless explicit permission obtained in writing this software cannot be distributed.
--
CREATE OR REPLACE FUNCTION public.rap_insert_%1$s(keyIn character, contentIn jsonb)
RETURNS boolean
LANGUAGE plpgsql
AS $function$
BEGIN
IF NOT EXISTS(
SELECT 1
FROM %1$s
WHERE key = keyIn
) THEN
INSERT INTO %1$s
VALUES(keyIn, contentIn, now());
ELSE
UPDATE %1$s
SET content = contentIn, timestamp = now()
WHERE key = keyIn;
END IF;
return true;
END;$function$
© 2015 - 2025 Weber Informatics LLC | Privacy Policy