Files
development/4dev/database/function/set_uid.sql
2022-12-06 09:27:08 +09:00

16 lines
307 B
PL/PgSQL

-- adds the created or updated date tags
CREATE OR REPLACE FUNCTION set_uid()
RETURNS TRIGGER AS
$$
DECLARE
random_length INT = 32; -- that should be long enough
BEGIN
IF TG_OP = 'INSERT' THEN
NEW.uid := random_string(random_length);
END IF;
RETURN NEW;
END;
$$
LANGUAGE 'plpgsql';