From: Gary Stainburn <gary.stainburn@ringways.co.uk>
To: pgsql-sql@postgresql.org
Subject: create function using language SQL
Date: Tue, 14 Aug 2001 13:40:05 +0100
Message-ID: <01081413400502.01217@gary.ringways.co.uk> (raw)
Hi all,
As I was reading up on create function etc. while learning plpgsql, I seam to
remember it stated that as well as plpgsql, that other languages are/will be
available including using SQL as the language. However, I cannot find the
syntax to create a function in SQL. Specifically, how you return the result.
As an example, how would I create a SQL function to match the plpgsql
function below?
CREATE FUNCTION getteamno(int4) RETURNS varchar AS '
DECLARE
unitno varchar;
BEGIN
select into unitno
tregion || ''/'' ||
to_char(tnumber,''FM000'')
from teams
where tid = $1;
if not found then
raise exception ''Team % not found'',$1;
return '''';
end if;
return unitno;
END;
' LANGUAGE 'plpgsql';
--
Gary Stainburn
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: gary.stainburn@ringways.co.uk
Subject: Re: create function using language SQL
In-Reply-To: <01081413400502.01217@gary.ringways.co.uk>
* 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