SQL function and input variables

From: Martín Marqués <martin(dot)marques(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: SQL function and input variables
Date: 2011-09-21 12:56:01
Message-ID: CABeG9Lti9uQ4BOq1wwFCrHXULL8xg52S_u5yNO6yUpQVQdAKFw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?

--
Martín Marqués
select 'martin.marques' || '@' || 'gmail.com'
DBA, Programador, Administrador

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2011-09-21 13:04:51 Re: SQL function and input variables
Previous Message Szymon Guz 2011-09-21 10:43:30 Re: Random multiple times