diff --git a/db/ddlutils/oracle/functions/Generate_UUID.sql b/db/ddlutils/oracle/functions/Generate_UUID.sql new file mode 100644 index 0000000000..9fd7d0fbc7 --- /dev/null +++ b/db/ddlutils/oracle/functions/Generate_UUID.sql @@ -0,0 +1,28 @@ +/* +*This file is part of Adempiere ERP Bazaar +*http://www.adempiere.org +* +*This program is free software; you can redistribute it and/or +*modify it under the terms of the GNU General Public License +*as published by the Free Software Foundation; either version 2 +*of the License, or (at your option) any later version. +* +*This program is distributed in the hope that it will be useful, +*but WITHOUT ANY WARRANTY; without even the implied warranty of +*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +*GNU General Public License for more details. +* +*You should have received a copy of the GNU General Public License +*along with this program; if not, write to the Free Software +*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.of +*/ +create or replace function generate_uuid return varchar as +guid varchar(32); +uuid varchar(36); +begin + guid := lower(sys_guid()); + uuid := substr(guid, 1, 8) || '-' || substr(guid, 9, 4) || '-' || substr(guid, 13, 4) || '-' || substr(guid, 17, 4) || '-' || substr(guid, 21, 12); + return uuid; +end; +/ + diff --git a/db/ddlutils/postgresql/functions/Generate_UUID.sql b/db/ddlutils/postgresql/functions/Generate_UUID.sql new file mode 100644 index 0000000000..9d0329028f --- /dev/null +++ b/db/ddlutils/postgresql/functions/Generate_UUID.sql @@ -0,0 +1,26 @@ +/* +*This file is part of Adempiere ERP Bazaar +*http://www.adempiere.org +* +*This program is free software; you can redistribute it and/or +*modify it under the terms of the GNU General Public License +*as published by the Free Software Foundation; either version 2 +*of the License, or (at your option) any later version. +* +*This program is distributed in the hope that it will be useful, +*but WITHOUT ANY WARRANTY; without even the implied warranty of +*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +*GNU General Public License for more details. +* +*You should have received a copy of the GNU General Public License +*along with this program; if not, write to the Free Software +*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.of +*/ + +CREATE OR REPLACE FUNCTION generate_uuid() +RETURNS char(36) AS $$ +BEGIN + return uuid_generate_v4()::char(36); +END; +$$ LANGUAGE plpgsql IMMUTABLE STRICT; + diff --git a/db/ddlutils/postgresql/uuid-ossp.sql b/db/ddlutils/postgresql/uuid-ossp.sql new file mode 100644 index 0000000000..d8f31a002d --- /dev/null +++ b/db/ddlutils/postgresql/uuid-ossp.sql @@ -0,0 +1,54 @@ +/* $PostgreSQL: pgsql/contrib/uuid-ossp/uuid-ossp.sql.in,v 1.6 2007/11/13 04:24:29 momjian Exp $ */ + +-- Adjust this setting to control where the objects get created. +SET search_path = public; + +CREATE OR REPLACE FUNCTION uuid_nil() +RETURNS uuid +AS '$libdir/uuid-ossp', 'uuid_nil' +IMMUTABLE STRICT LANGUAGE C; + +CREATE OR REPLACE FUNCTION uuid_ns_dns() +RETURNS uuid +AS '$libdir/uuid-ossp', 'uuid_ns_dns' +IMMUTABLE STRICT LANGUAGE C; + +CREATE OR REPLACE FUNCTION uuid_ns_url() +RETURNS uuid +AS '$libdir/uuid-ossp', 'uuid_ns_url' +IMMUTABLE STRICT LANGUAGE C; + +CREATE OR REPLACE FUNCTION uuid_ns_oid() +RETURNS uuid +AS '$libdir/uuid-ossp', 'uuid_ns_oid' +IMMUTABLE STRICT LANGUAGE C; + +CREATE OR REPLACE FUNCTION uuid_ns_x500() +RETURNS uuid +AS '$libdir/uuid-ossp', 'uuid_ns_x500' +IMMUTABLE STRICT LANGUAGE C; + +CREATE OR REPLACE FUNCTION uuid_generate_v1() +RETURNS uuid +AS '$libdir/uuid-ossp', 'uuid_generate_v1' +VOLATILE STRICT LANGUAGE C; + +CREATE OR REPLACE FUNCTION uuid_generate_v1mc() +RETURNS uuid +AS '$libdir/uuid-ossp', 'uuid_generate_v1mc' +VOLATILE STRICT LANGUAGE C; + +CREATE OR REPLACE FUNCTION uuid_generate_v3(namespace uuid, name text) +RETURNS uuid +AS '$libdir/uuid-ossp', 'uuid_generate_v3' +IMMUTABLE STRICT LANGUAGE C; + +CREATE OR REPLACE FUNCTION uuid_generate_v4() +RETURNS uuid +AS '$libdir/uuid-ossp', 'uuid_generate_v4' +VOLATILE STRICT LANGUAGE C; + +CREATE OR REPLACE FUNCTION uuid_generate_v5(namespace uuid, name text) +RETURNS uuid +AS '$libdir/uuid-ossp', 'uuid_generate_v5' +IMMUTABLE STRICT LANGUAGE C;