Received: from thor.tht.net (thor.tht.net [209.47.145.4]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eB8EEhZ77031 for ; Fri, 8 Dec 2000 09:14:43 -0500 (EST) (envelope-from rudy@heymax.com) Received: from heymax.com (mail.heymax.com [63.96.5.101]) by thor.tht.net (8.9.3/8.9.3) with ESMTP id KAA08779 for ; Fri, 8 Dec 2000 10:14:51 GMT (envelope-from rudy@heymax.com) Received: from heymax.com [10.0.1.22] by heymax.com [10.0.1.2] with SMTP (MDaemon.v3.5.0.R) for ; Fri, 08 Dec 2000 09:18:02 -0500 Message-ID: <3A30ED00.39D9D6C9@heymax.com> Date: Fri, 08 Dec 2000 09:15:28 -0500 From: rudy X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: CURSOR HELP Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-MDRemoteIP: 10.0.1.22 X-Return-Path: rudy@heymax.com X-MDaemon-Deliver-To: pgsql-admin@postgresql.org X-Archive-Number: 200012/46 X-Sequence-Number: 238 HELP. I apologize if this is too basic, but since I have next to zero documentation on it I must ask... Can you declare and use a CURSOR in a plpgsql function? The documentation I have read seems to indicate that you can, but I have not been able to get it to work. I can get a similar function to work in SQL from the command prompt, but not when using a plpgsql function. Here is a snippet of code: DECLARE recur_events_curs CURSOR FOR SELECT time_start, time_end FROM CHAT_EVENT WHERE day_of_week = v_day_of_week AND id_resource = v_id_resource; v_this_start_time CHAT_EVENT.time_start%TYPE; v_this_end_time CHAT_EVENT.time_end%TYPE; IF v_end_time <= v_start_time THEN /* Recurring event spans two days of the week */ v_use_end_time := v_end_time + 2400; ELSE v_use_end_time := v_end_time; END IF; /* First, determine if this event overlaps any recurring events */ OPEN recur_events_curs; LOOP FETCH recur_events_curs INTO v_this_start_time, v_this_end_time; EXIT WHEN recur_events_curs ISNULL; I always get an error on the "CURSOR" during compile of function. Thanks, Rudy