X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 59D2952A46 for ; Tue, 12 Jul 2005 14:47:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27885-03 for ; Tue, 12 Jul 2005 17:46:59 +0000 (GMT) Received: from relay.pair.com (relay00.pair.com [209.68.1.20]) by svr1.postgresql.org (Postfix) with SMTP id 5DBD352A1F for ; Tue, 12 Jul 2005 14:46:58 -0300 (ADT) Received: (qmail 30268 invoked from network); 12 Jul 2005 17:46:57 -0000 Received: from unknown (HELO oper2) (unknown) by unknown with SMTP; 12 Jul 2005 17:46:57 -0000 X-pair-Authenticated: 200.55.15.181 Message-ID: <00c601c58709$fce8d560$6501a8c0@oper2> From: =?iso-8859-1?Q?Sebastian_K=FChner?= To: Subject: LOOP and EXIT Date: Tue, 12 Jul 2005 14:49:00 -0300 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1506 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.207 tagged_above=0 required=5 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200507/90 X-Sequence-Number: 18146 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