From: | ananthreddy(at)yahoo(dot)com (ananth) |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Error in executing plpgsql function |
Date: | 2001-12-01 06:23:35 |
Message-ID: | 5304e92b.0111302223.5e89b405@posting.google.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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'
==========================================
From | Date | Subject | |
---|---|---|---|
Next Message | James Thornton | 2001-12-01 09:44:52 | update returns 1, but no changes have been made |
Previous Message | Tom Lane | 2001-12-01 05:21:16 | Re: contracting tables |