create function using language SQL - Mailing list pgsql-sql

From Gary Stainburn
Subject create function using language SQL
Date
Msg-id 01081413400502.01217@gary.ringways.co.uk
Whole thread Raw
Responses Re: create function using language SQL  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
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;
ifnot 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     


pgsql-sql by date:

Previous
From: Jan Wieck
Date:
Subject: Re: on update restrict
Next
From: "William Courtier"
Date:
Subject: Re: Are circular REFERENCES possible ?