Index: openacs-4/packages/acs-kernel/sql/oracle/acs-objects-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/acs-objects-create.sql,v diff -u -r1.3 -r1.3.2.1 --- openacs-4/packages/acs-kernel/sql/oracle/acs-objects-create.sql 4 Sep 2001 04:50:05 -0000 1.3 +++ openacs-4/packages/acs-kernel/sql/oracle/acs-objects-create.sql 9 Mar 2002 23:34:32 -0000 1.3.2.1 @@ -496,6 +496,8 @@ object_id in acs_objects.object_id%TYPE ) is + declare + v_exists_p char; begin -- Delete dynamic/generic attributes @@ -509,11 +511,19 @@ where o.object_id = acs_object.delete.object_id) connect by object_type = prior supertype) loop - -- Delete from the table. - execute immediate 'delete from ' || object_type.table_name || + -- Delete from the table if it exists. + select case when count(*) = 0 then 'f' else 't' end into v_exists_p + from user_tables + where table_name = upper(object_type.table_name); + + if v_exists_p = 't' then + execute immediate 'delete from ' || object_type.table_name || ' where ' || object_type.id_column || ' = :object_id' - using in object_id; + using in object_id; + end if; + end loop; + end delete; function name ( Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql,v diff -u -r1.29 -r1.29.2.1 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql 27 Jan 2002 00:19:36 -0000 1.29 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql 9 Mar 2002 23:34:32 -0000 1.29.2.1 @@ -713,9 +713,14 @@ -- because the table names appear to be stored in upper case. Quoting -- causes them to not match the actual lower or potentially mixed-case -- table names. We will just forbid squirrely names that include quotes. +-- daveB +-- ETP is creating a new object, but not a table, although it does specify a +-- table name, so we need to check if the table exists. Wp-slim does this too - execute ''delete from '' || obj_type.table_name || - '' where '' || obj_type.id_column || '' = '' || delete__object_id; + if table_exists(obj_type.table_name) then + execute ''delete from '' || obj_type.table_name || + '' where '' || obj_type.id_column || '' = '' || delete__object_id; + end if; end loop; return 0; Index: openacs-4/packages/acs-kernel/sql/postgresql/community-core-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/community-core-create.sql,v diff -u -r1.8 -r1.8.2.1 --- openacs-4/packages/acs-kernel/sql/postgresql/community-core-create.sql 23 Feb 2002 02:37:36 -0000 1.8 +++ openacs-4/packages/acs-kernel/sql/postgresql/community-core-create.sql 9 Mar 2002 23:34:32 -0000 1.8.2.1 @@ -665,6 +665,8 @@ -- create or replace package body acs_user -- function new select define_function_args('user__new','user_id,object_type;user,creation_date;now(),creation_user,creation_ip,email,url,first_names,last_name,password,salt,password_question,password_answer,screen_name,email_verified_p;t,context_id'); + + create function acs_user__new (integer,varchar,timestamp,integer,varchar,varchar,varchar,varchar,varchar,char,char,varchar,varchar,varchar,boolean,integer) returns integer as ' declare @@ -685,12 +687,23 @@ new__email_verified_p alias for $15; -- default ''t'' new__context_id alias for $16; -- default null v_user_id users.user_id%TYPE; + person_exists varchar; begin + v_user_id := new__user_id; + + select case when count(*) = 0 then ''f'' else ''t'' end into person_exists + from persons where person_id = v_user_id; + + if person_exists = ''f'' then + v_user_id := - person__new(new__user_id, new__object_type, + person__new(v_user_id, new__object_type, new__creation_date, new__creation_user, new__creation_ip, new__email, new__url, new__first_names, new__last_name, new__context_id); + else + update acs_objects set object_type = ''user'' where object_id = v_user_id; + end if; insert into users (user_id, password, salt, password_question, password_answer, screen_name, @@ -708,6 +721,7 @@ end;' language 'plpgsql'; + create function acs_user__new(varchar,varchar,varchar,char,char) returns integer as ' declare