Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fB16cpm29198 for ; Sat, 1 Dec 2001 01:38:51 -0500 (EST) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id fB16Ncd29276 for pgsql-sql@postgresql.org; Sat, 1 Dec 2001 01:23:38 -0500 (EST) (envelope-from news) From: ananthreddy@yahoo.com (ananth) X-Newsgroups: comp.databases.postgresql.sql Subject: Error in executing plpgsql function Date: 30 Nov 2001 22:23:35 -0800 Organization: http://groups.google.com/ Lines: 87 Message-ID: <5304e92b.0111302223.5e89b405@posting.google.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-sql@postgresql.org X-Archive-Number: 200112/23 X-Sequence-Number: 5846 Hi Everyone, I am newbie and writing a plpgsql function. I have included source code here for function. When I execute this function where it finds a row in table it works fine and gives expected output. The problem is when I run this function by passing a parameter values where row does not exist in table. I expect it to print message and return false. Instead it disconnects from server and throughs lot of errors in log file. Here is output from executing this function ====When row is found====== called from psql test=# select func1('2'); NOTICE: Value of ID 2 NOTICE: Value of NDI1 NOTICE: Value of CSSG 5007 NOTICE: Value of Interval Discharge func1 ------- t (1 row) ======when row is not found===== test=# select func1('99'); pqReadData() -- backend closed the channel unexpectedly. This probably means the backend terminated abnormally before or while processing the request. The connection to the server was lost. Attempting reset: Failed. !# =====also i see following errors in server logfile=== Server process (pid 21536) exited with status 139 at Fri Nov 30 22:28:57 2001 Terminating any active server processes... Server processes were terminated at Fri Nov 30 22:28:57 2001 Reinitializing shared memory and semaphores The Data Base System is starting up DEBUG: database system was interrupted at 2001-11-30 22:06:39 PST DEBUG: CheckPoint record at (0, 185703020) DEBUG: Redo record at (0, 185703020); Undo record at (0, 0); Shutdown TRUE DEBUG: NextTransactionId: 2177; NextOid: 1034695 DEBUG: database system was not properly shut down; automatic recovery in progress... DEBUG: ReadRecord: record with zero len at (0, 185703084) DEBUG: redo is not required DEBUG: database system is in production state Any idea what is happeing? Appreciate any help? BTW- where can I find good documentation on plpgsql functions? TIA ananth =======Function code======== DROP FUNCTION func1(text); create function func1(text) returns bool as ' declare key alias for $1; ndiraw_rec ndiraw%rowtype; begin select into ndiraw_rec * from ndiraw where ID=key; if not found then raise notice ''Record Not found for key %'', key; return false; end if; raise notice ''Value of ID %'', ndiraw_rec.ID ; raise notice ''Value of NDI1 %'',ndiraw_rec.NDI1; raise notice ''Value of CSSG %'',ndiraw_rec.cssg; raise notice ''Value of Interval %'',ndiraw_rec.interval; return true; end; ' language 'plpgsql' ==========================================