pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: rudy <rudy@heymax.com>
To: pgsql-admin@postgresql.org
Subject: CURSOR HELP
Date: Fri, 08 Dec 2000 09:15:28 -0500
Message-ID: <3A30ED00.39D9D6C9@heymax.com> (raw)

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






Message-ID: <3A30ED00.39D9D6C9@heymax.com>
Permalink:  ../3A30ED00.39D9D6C9@heymax.com/
Also on:    postgresql.org/message-id/3A30ED00.39D9D6C9@heymax.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: rudy@heymax.com
  Subject: Re: CURSOR HELP
  In-Reply-To: <3A30ED00.39D9D6C9@heymax.com>
  References: <3A30ED00.39D9D6C9@heymax.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox