Re: SQL function and input variables

Поиск
Список
Период
Сортировка
От Martín Marqués
Тема Re: SQL function and input variables
Дата
Msg-id CABeG9LvHsrBHLRpfVdxZuQoKDEizuBRnqsrqodd-5pDQyjjEfw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: SQL function and input variables  (Thomas Kellerer <spam_eater@gmx.net>)
Ответы Re: SQL function and input variables
Список pgsql-general
2011/9/21 Thomas Kellerer <spam_eater@gmx.net>:
> Martín Marqués, 21.09.2011 14:56:
>>
>> 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?
>>
> This is because the language SQL does not support named parameters, only
> positional ones.
>
> http://www.postgresql.org/docs/current/static/xfunc-sql.html#XFUNC-NAMED-PARAMETERS

Thanks for the tip. Didn't know that, and just kept using plpgsql sintax.

Thanks again.

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

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

Предыдущее
От: Thomas Kellerer
Дата:
Сообщение: Re: SQL function and input variables
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Date time value error in Ms Access using pass through queries