Re: Trying to avoid a simple temporary variable declaration in a pl/pgsql function
В списке pgsql-general по дате отправления:
| От | Tom Lane |
|---|---|
| Тема | Re: Trying to avoid a simple temporary variable declaration in a pl/pgsql function |
| Дата | |
| Msg-id | 44911.1434812204@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Trying to avoid a simple temporary variable declaration in a pl/pgsql function ("David G. Johnston" <david.g.johnston@gmail.com>) |
| Ответы |
Re: Trying to avoid a simple temporary variable declaration
in a pl/pgsql function
|
| Список | pgsql-general |
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> I know this could be written quite easily in sql but was wondering if it is
> possible in pl/pgsql.
> CREATE FUNCTION test_func()
> RETURNS text
> LANGUAGE 'plpgsql'
> AS $$
> BEGIN
> SELECT 'text_to_return' INTO <what_goes_here?>; --with or without a cast
> RETURN <what_goes_here?>;
> END;
> $$;
> The goal is to return the value of text_to_return without declaring an
> explicit variable to name in the INTO clause.
INTO requires a declared variable as target.
However, I'm wondering why you don't just use "RETURN expression"
if this is all that will be in the function.
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера