From: | "Tuttle, Gene" <cetuttle(at)rottlundhomes(dot)com> |
---|---|
To: | "'pgsql-admin(at)postgresql(dot)org'" <pgsql-admin(at)postgresql(dot)org> |
Subject: | PL/pgsql |
Date: | 2004-06-29 20:52:37 |
Message-ID: | 199F7F755B80D511877100B0D0F0B76CC3FDE3@mail.rottlundhomes.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
I am new to Postgresql and am having problems getting functions working.
I have been following an example in the book "PostgreSQL" by Douglas &
Douglas Published by Developers Library.
I put the code in as a function (see end of email)
When I execute it from psql I get the following:
dev=# select my_factorial(1);
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
Can any one help me find the problem. point me in the right direction?
Thanks
Gene Tuttle
-- Function: public.my_factorial(int4)
-- DROP FUNCTION public.my_factorial(int4);
CREATE OR REPLACE FUNCTION public.my_factorial(int4)
RETURNS int4 AS
'
DECLARE
arg INTEGER;
BEGIN
arg := $1;
IF arg IS NULL or arg < 0 THEN
RAISE NOTICE \'Invalid Number\';
RETURN NULL;
ELSE
IF arg = 1 THEN
RETURN 1;
ELSE
DECLARE
next_value INTEGER;
BEGIN
next_value := my_factorial(arg - 1) * arg;
RETURN next_value;
END;
END IF;
END IF;
END;
'
LANGUAGE 'plpgsql' VOLATILE;
From | Date | Subject | |
---|---|---|---|
Next Message | Gaetano Mendola | 2004-06-29 21:19:09 | Re: How to list what queries are running in postgres? |
Previous Message | Simon Riggs | 2004-06-29 20:39:07 | PITR Error Message assistance |