Index: openacs-4/packages/survey/sql/postgresql/survey-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/survey/sql/postgresql/survey-create.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/survey/sql/postgresql/survey-create.sql	15 Sep 2002 23:57:48 -0000	1.1
+++ openacs-4/packages/survey/sql/postgresql/survey-create.sql	16 Sep 2002 01:04:53 -0000	1.2
@@ -255,28 +255,11 @@
 );
 
 
-create index survey_response_index on survey_question_responses (response_id, question_id);
-create index survey_q_r_choice_id on survey_question_responses(choice_id);
-create index survey_q_r_attachment_answer on survey_question_responses(attachment_answer);
-
-
 -- this view contains only the most recently edited version
 -- of each survey response.
 
-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
-  from survey_responses sr 
-  join acs_objects o
-    on (sr.response_id = o.object_id)
-  join (select max(response_id) as response_id
-          from survey_responses
-         group by survey_response__initial_response_id(response_id)) latest
-    on (sr.response_id = latest.response_id);
 
 
-
 -- this table stores the answers to each question for a survey
 -- we want to be able to hold different data types in one long skinny table 
 -- but we also may want to do averages, etc., so we can't just use CLOBs
@@ -307,14 +290,8 @@
                                 on delete cascade
 );
 
-
-create or replace view survey_ques_responses_latest as
-select qr.*
-  from survey_question_responses qr, survey_responses_latest r
- where qr.response_id=r.response_id;  
-
-
-
+create index survey_q_r_choice_id on survey_question_responses(choice_id);
+create index survey_q_r_attachment_answer on survey_question_responses(attachment_answer);
 create index survey_response_index on survey_question_responses (response_id, question_id);
 
 -- We create a view that selects out only the last response from each
@@ -415,8 +392,6 @@
 
 end;' language 'plpgsql';
 
-
-
 create function survey_section__delete (integer)
 returns integer as '
 declare
@@ -431,8 +406,6 @@
 
 end;' language 'plpgsql';
 
-
-
 create function survey_question__new (integer,integer,integer,text,varchar,boolean,boolean,varchar,varchar,varchar,integer,integer)
 returns integer as '
 declare
@@ -565,3 +538,20 @@
 
 end;' language 'plpgsql';
 
+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
+  from survey_responses sr 
+  join acs_objects o
+    on (sr.response_id = o.object_id)
+  join (select max(response_id) as response_id
+          from survey_responses
+         group by survey_response__initial_response_id(response_id)) latest
+    on (sr.response_id = latest.response_id);
+
+create view survey_ques_responses_latest as
+select qr.*
+  from survey_question_responses qr, survey_responses_latest r
+ where qr.response_id=r.response_id;  
+
