pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sebastian Kühner <support@veraza.com>
To: pgsql-admin@postgresql.org
Subject: LOOP and EXIT
Date: Tue, 12 Jul 2005 14:49:00 -0300
Message-ID: <00c601c58709$fce8d560$6501a8c0@oper2> (raw)

Hello,

I'm new here in this group... and I hope that I find the solution for my
problem here.

I wrote a simple function which looks like this:

CREATE OR REPLACE FUNCTION watchdog() RETURNS TIME AS '
 DECLARE
  watchdog_control RECORD;
  help RECORD;
 BEGIN
  LOOP
   PERFORM * FROM watchdog_ctl;

   IF NOT FOUND THEN
    EXIT;
   END IF;

   PERFORM sleep(3);

  END LOOP;
  RETURN now();
 END;
' LANGUAGE plpgsql;

That means that I want to leave the loop if there isn't an entry in the
table watchdog_ctl. This works fine if the table is empty at the startup of
the function (select watchdog();). But if I empty the table watchdog_ctl
while the function is running it seems to be an endless loop. Hay anyone of
you an idea why??

Many thanks!

Sebastian





view thread (2+ messages)  latest in thread

Message-ID: <00c601c58709$fce8d560$6501a8c0@oper2>
Permalink:  ../00c601c58709$fce8d560$6501a8c0@oper2/
Also on:    postgresql.org/message-id/00c601c58709$fce8d560$6501a8c0@oper2

 · 

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: support@veraza.com
  Subject: Re: LOOP and EXIT
  In-Reply-To: <00c601c58709$fce8d560$6501a8c0@oper2>
  References: <00c601c58709$fce8d560$6501a8c0@oper2>

* 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