Index: openacs-4/packages/acs-events/sql/postgresql/acs-events-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-events/sql/postgresql/acs-events-create.sql,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/acs-events/sql/postgresql/acs-events-create.sql	14 May 2002 05:05:26 -0000	1.4
+++ openacs-4/packages/acs-events/sql/postgresql/acs-events-create.sql	13 Aug 2002 19:03:33 -0000	1.5
@@ -753,23 +753,35 @@
         v_one_end_date               timestamp;
 BEGIN
         -- get the initial offsets
-        select start_date, end_date into v_one_start_date, v_one_end_date
-        from time_intervals, timespans, acs_events
-        where time_intervals.interval_id = timespans.interval_id and
-        timespans.timespan_id = acs_events.timespan_id and
-        event_id= recurrence_timespan_edit.event_id;
+        select start_date,
+               end_date into v_one_start_date,
+               v_one_end_date
+        from time_intervals, 
+             timespans, 
+             acs_events 
+        where time_intervals.interval_id = timespans.interval_id
+          and timespans.timespan_id = acs_events.timespan_id
+          and event_id=p_event_id;
 
-        FOR v_timespan in 
-        (select * from time_intervals where interval_id in (select interval_id from timespans where timespan_id in (select timespan_id from acs_events where recurrence_id = (select recurrence_id from acs_events where event_id = recurrence_timespan_edit.event_id))))
+        FOR v_timespan in
+            select *
+            from time_intervals
+            where interval_id in (select interval_id
+                                  from timespans 
+                                  where timespan_id in (select timespan_id
+                                                        from acs_events 
+                                                        where recurrence_id = (select recurrence_id 
+                                                                               from acs_events where event_id = p_event_id)))
         LOOP
-                PERFORM time_interval__edit(v_timespan.interval_id, v_timespan.start_date + (p_start_date - v_one_start_date), v_timespan.end_date + (p_end_date - v_one_end_date));
+                PERFORM time_interval__edit(v_timespan.interval_id, 
+                                            v_timespan.start_date + (p_start_date - v_one_start_date), 
+                                            v_timespan.end_date + (p_end_date - v_one_end_date));
         END LOOP;
 
-        return p_recurrence_id;
+        return p_event_id;
 END;
 ' language 'plpgsql';
 
-
 create function acs_event__activity_set (
        --
        -- Sets the activity for an event (20.10.20)
