tao-test/app/tao/install/db/tao_stored_procedures_pgsql.sql

17 lines
548 B
MySQL
Raw Normal View History

2022-08-29 20:14:13 +02:00
-- sequence_uri_provider_uri_sequence_seq --> name of the sequence for currval()
-- it is generated automatically by postgres
CREATE OR REPLACE FUNCTION generis_sequence_uri_provider(modeluri varchar)
RETURNS varchar
LANGUAGE plpgsql
VOLATILE
AS $$
DECLARE uri varchar;
DECLARE stamp int;
BEGIN
INSERT INTO sequence_uri_provider DEFAULT VALUES;
SELECT INTO stamp extract(epoch FROM now())::int;
uri := modeluri || 'i' || stamp || FLOOR(RANDOM() * 10000) || currval('sequence_uri_provider_uri_sequence_seq');
RETURN uri;
END
$$;