From afe377a9b10b5c1b2badc74d4b9b636e7c4d0cbf Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 27 Jan 2015 18:01:45 +0100 Subject: Add E-R model and SQL bootstrap scripts --- res/sql/functions/orcl_current_datetime.sql | 10 ++++++++++ res/sql/functions/orcl_gen_uuid.sql | 11 +++++++++++ res/sql/functions/pg_current_datetime.sql | 10 ++++++++++ res/sql/functions/pg_gen_uuid.sql | 9 +++++++++ 4 files changed, 40 insertions(+) create mode 100644 res/sql/functions/orcl_current_datetime.sql create mode 100644 res/sql/functions/orcl_gen_uuid.sql create mode 100644 res/sql/functions/pg_current_datetime.sql create mode 100644 res/sql/functions/pg_gen_uuid.sql (limited to 'res/sql/functions') diff --git a/res/sql/functions/orcl_current_datetime.sql b/res/sql/functions/orcl_current_datetime.sql new file mode 100644 index 0000000..bf454d8 --- /dev/null +++ b/res/sql/functions/orcl_current_datetime.sql @@ -0,0 +1,10 @@ +CREATE OR REPLACE FUNCTION current_datetime + RETURN TIMESTAMP WITH TIME ZONE +AS + BEGIN + +--RETURN TO_TIMESTAMP_TZ('2014-01-01', 'YYYY-MM-DD'); + RETURN CURRENT_TIMESTAMP; + + END; +/ diff --git a/res/sql/functions/orcl_gen_uuid.sql b/res/sql/functions/orcl_gen_uuid.sql new file mode 100644 index 0000000..466fe65 --- /dev/null +++ b/res/sql/functions/orcl_gen_uuid.sql @@ -0,0 +1,11 @@ +CREATE OR REPLACE FUNCTION gen_uuid + RETURN VARCHAR +AS + BEGIN + + RETURN regexp_replace(rawtohex(sys_guid()) + , '([A-F0-9]{8})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{12})' + , '\1-\2-\3-\4-\5'); + + END; +/ diff --git a/res/sql/functions/pg_current_datetime.sql b/res/sql/functions/pg_current_datetime.sql new file mode 100644 index 0000000..75b1b96 --- /dev/null +++ b/res/sql/functions/pg_current_datetime.sql @@ -0,0 +1,10 @@ +CREATE OR REPLACE FUNCTION current_datetime() + RETURNS TIMESTAMP WITH TIME ZONE +AS ' +BEGIN + +--RETURN to_timestamp(''2014-01-01'', ''YYYY-MM-DD''); + RETURN now(); + +END; +' LANGUAGE plpgsql; diff --git a/res/sql/functions/pg_gen_uuid.sql b/res/sql/functions/pg_gen_uuid.sql new file mode 100644 index 0000000..c592385 --- /dev/null +++ b/res/sql/functions/pg_gen_uuid.sql @@ -0,0 +1,9 @@ +CREATE OR REPLACE FUNCTION gen_uuid() + RETURNS VARCHAR +AS ' +BEGIN + + RETURN upper(cast(uuid_generate_v4() AS VARCHAR)); + +END; +' LANGUAGE plpgsql; -- cgit v1.2.3