SQL function and input variables

Поиск
Список
Период
Сортировка
От Martín Marqués
Тема SQL function and input variables
Дата
Msg-id CABeG9Lti9uQ4BOq1wwFCrHXULL8xg52S_u5yNO6yUpQVQdAKFw@mail.gmail.com
обсуждение исходный текст
Ответы Re: SQL function and input variables
Re: SQL function and input variables
Список 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Szymon Guz
Дата:
Сообщение: Re: Random multiple times
Следующее
От: Raymond O'Donnell
Дата:
Сообщение: Re: SQL function and input variables