Index: openacs-4/contrib/packages/survey/sql/postgresql/survey-package-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/survey/sql/postgresql/Attic/survey-package-create.sql,v
diff -u -N -r1.2.2.1 -r1.2.2.2
--- openacs-4/contrib/packages/survey/sql/postgresql/survey-package-create.sql	19 Mar 2004 10:46:40 -0000	1.2.2.1
+++ openacs-4/contrib/packages/survey/sql/postgresql/survey-package-create.sql	6 May 2004 06:01:40 -0000	1.2.2.2
@@ -309,17 +309,6 @@
   return v_initial_response_id;
 end;' language 'plpgsql';
 
-create or replace function survey_response__initial_user_id (integer)
-returns integer as '
-declare
-p_response_id 	alias for $1;
-v_user_id	integer;
-begin
-	select into v_user_id creation_user
-	from acs_objects where
-	object_id = survey_response__initial_response_id(p_response_id);
-return v_user_id;
-end;' language 'plpgsql';
 
 -- procedure delete 
 create or replace function survey_response__remove(integer)
@@ -399,10 +388,12 @@
 create view survey_responses_latest as
 select sr.*, o.creation_date, 
        o.creation_user,
-       survey_response__initial_user_id(sr.response_id) as initial_user_id
+       o2.creation_user as initial_user_id
   from survey_responses sr 
   join acs_objects o
     on (sr.response_id = o.object_id)
+  join acs_objects o2
+    on (coalesce(sr.initial_response_id, sr.response_id) = o2.object_id)
   join (select max(response_id) as response_id
           from survey_responses
          group by survey_response__initial_response_id(response_id)) latest
