diff options
author | Pacien TRAN-GIRARD | 2015-01-27 18:01:45 +0100 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2015-01-27 18:27:51 +0100 |
commit | afe377a9b10b5c1b2badc74d4b9b636e7c4d0cbf (patch) | |
tree | e6808c16b8bf7b7a2cd79435706465181cbe4295 /res/sql/functions | |
parent | 999d0ebce6b2f4ba39ee55daa52ca33f5fac657c (diff) | |
download | minibay-afe377a9b10b5c1b2badc74d4b9b636e7c4d0cbf.tar.gz |
Add E-R model and SQL bootstrap scripts
Diffstat (limited to 'res/sql/functions')
-rw-r--r-- | res/sql/functions/orcl_current_datetime.sql | 10 | ||||
-rw-r--r-- | res/sql/functions/orcl_gen_uuid.sql | 11 | ||||
-rw-r--r-- | res/sql/functions/pg_current_datetime.sql | 10 | ||||
-rw-r--r-- | res/sql/functions/pg_gen_uuid.sql | 9 |
4 files changed, 40 insertions, 0 deletions
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 @@ | |||
1 | CREATE OR REPLACE FUNCTION current_datetime | ||
2 | RETURN TIMESTAMP WITH TIME ZONE | ||
3 | AS | ||
4 | BEGIN | ||
5 | |||
6 | --RETURN TO_TIMESTAMP_TZ('2014-01-01', 'YYYY-MM-DD'); | ||
7 | RETURN CURRENT_TIMESTAMP; | ||
8 | |||
9 | END; | ||
10 | / | ||
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 @@ | |||
1 | CREATE OR REPLACE FUNCTION gen_uuid | ||
2 | RETURN VARCHAR | ||
3 | AS | ||
4 | BEGIN | ||
5 | |||
6 | RETURN regexp_replace(rawtohex(sys_guid()) | ||
7 | , '([A-F0-9]{8})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{12})' | ||
8 | , '\1-\2-\3-\4-\5'); | ||
9 | |||
10 | END; | ||
11 | / | ||
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 @@ | |||
1 | CREATE OR REPLACE FUNCTION current_datetime() | ||
2 | RETURNS TIMESTAMP WITH TIME ZONE | ||
3 | AS ' | ||
4 | BEGIN | ||
5 | |||
6 | --RETURN to_timestamp(''2014-01-01'', ''YYYY-MM-DD''); | ||
7 | RETURN now(); | ||
8 | |||
9 | END; | ||
10 | ' 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 @@ | |||
1 | CREATE OR REPLACE FUNCTION gen_uuid() | ||
2 | RETURNS VARCHAR | ||
3 | AS ' | ||
4 | BEGIN | ||
5 | |||
6 | RETURN upper(cast(uuid_generate_v4() AS VARCHAR)); | ||
7 | |||
8 | END; | ||
9 | ' LANGUAGE plpgsql; | ||