From: | Raymond O'Donnell <rod(at)iol(dot)ie> |
---|---|
To: | Martín Marqués <martin(dot)marques(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: SQL function and input variables |
Date: | 2011-09-21 13:04:51 |
Message-ID: | 4E79E0F3.1050409@iol.ie |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)iol(dot)ie
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Kellerer | 2011-09-21 13:07:24 | Re: SQL function and input variables |
Previous Message | Martín Marqués | 2011-09-21 12:56:01 | SQL function and input variables |