Index: openacs-4/packages/acs-kernel/acs-kernel.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/acs-kernel.info,v diff -u -r1.136.2.25 -r1.136.2.26 --- openacs-4/packages/acs-kernel/acs-kernel.info 20 Dec 2016 20:28:49 -0000 1.136.2.25 +++ openacs-4/packages/acs-kernel/acs-kernel.info 21 Dec 2016 00:14:56 -0000 1.136.2.26 @@ -9,15 +9,15 @@ f t - + OpenACS Core Team Routines and data models providing the foundation for OpenACS-based Web services. 2016-09-06 OpenACS The OpenACS kernel contains the core datamodel create and drop scripts for such things as objects, groups, partiies and the supporting PL/SQL and PL/pgSQL procedures. 3 - + Index: openacs-4/packages/acs-kernel/sql/oracle/utilities-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/utilities-create.sql,v diff -u -r1.3.2.1 -r1.3.2.2 --- openacs-4/packages/acs-kernel/sql/oracle/utilities-create.sql 20 Dec 2016 20:28:49 -0000 1.3.2.1 +++ openacs-4/packages/acs-kernel/sql/oracle/utilities-create.sql 21 Dec 2016 00:14:56 -0000 1.3.2.2 @@ -64,6 +64,13 @@ table IN varchar2, column IN varchar2) return LONG; + + TYPE primary_keys IS TABLE OF varchar2; + + function get_primary_keys(table IN varchar2) + return primary_keys + PIPELINED; + end util; / show errors @@ -225,8 +232,24 @@ FROM ALL_TAB_COLUMNS WHERE table_name = table AND column_name = column); - END get_default; + END get_default; + function get_primary_keys(table IN varchar2) + return primary_keys IS + rec primary_keys; + BEGIN + SELECT cols.column_name + BULK COLLECT INTO rec + FROM all_constraints cons, all_cons_columns cols + WHERE cols.table_name = table + AND cons.constraint_type = 'P' + AND cons.constraint_name = cols.constraint_name + AND cons.owner = cols.owner + ORDER BY cols.table_name, cols.position; + + RETURN rec; + END get_primary_keys; + end util; / show errors Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/acs-kernel/sql/oracle/upgrade/upgrade-5.9.1d19-5.9.1d20.sql'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/acs-kernel/sql/postgresql/utilities-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/utilities-create.sql,v diff -u -r1.8.2.1 -r1.8.2.2 --- openacs-4/packages/acs-kernel/sql/postgresql/utilities-create.sql 20 Dec 2016 20:28:49 -0000 1.8.2.1 +++ openacs-4/packages/acs-kernel/sql/postgresql/utilities-create.sql 21 Dec 2016 00:14:56 -0000 1.8.2.2 @@ -282,3 +282,20 @@ and column_name = p_column); END; $$ LANGUAGE plpgsql; + +-- added +select define_function_args('util__get_primary_keys','table'); + +-- +-- procedure util__get_primary_keys/1 +-- +CREATE OR REPLACE FUNCTION util__get_primary_keys( + p_table text +) RETURNS SETOF pg_attribute.attname%TYPE AS $$ + SELECT a.attname + FROM pg_index i + JOIN pg_attribute a ON a.attrelid = i.indrelid + AND a.attnum = ANY(i.indkey) + WHERE i.indrelid = p_table::regclass + AND i.indisprimary; +$$ LANGUAGE sql; Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.9.1d19-5.9.1d20.sql'. Fisheye: No comparison available. Pass `N' to diff?