Re: SQL function and input variables - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: SQL function and input variables
Date
Msg-id 4E79E0F3.1050409@iol.ie
Whole thread Raw
In response to SQL function and input variables  (Martín Marqués <martin.marques@gmail.com>)
List pgsql-general
On 21/09/2011 13:56, Martín Marqués wrote:
> I was makeing an SQL function and got an error which on a sintax that
> I thouhgt would work:
>
> CREATE OR REPLACE FUNCTION dicInsertarPalabra(p TEXT)
> RETURNS INT AS $body$
>     INSERT INTO public.diccionario (palabra) VALUES (quote_literal(p));
>     SELECT COALESCE(codigo,0) FROM public.diccionario
>            WHERE palabra = quote_literal(p);
> $body$ LANGUAGE 'SQL';
>
> Changing p for $1 in the body of the function makes it work. But,
> can't we label input arguments like how I did here?
>

No, you can't - that works in pl/pgsql, but not in SQL.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

pgsql-general by date:

Previous
From: Martín Marqués
Date:
Subject: SQL function and input variables
Next
From: Thomas Kellerer
Date:
Subject: Re: SQL function and input variables