Re: Why I cannot call a function from within an SQL function?

Поиск
Список
Период
Сортировка
От Ketema Harris
Тема Re: Why I cannot call a function from within an SQL function?
Дата
Msg-id E03B6EBC-44F7-4F59-A43A-5982A53CFB95@ketema.net
обсуждение исходный текст
Ответ на Re: Why I cannot call a function from within an SQL function?  (Eus <eus@member.fsf.org>)
Ответы Re: Why I cannot call a function from within an SQL function?  (Eus <eus@member.fsf.org>)
Список pgsql-general
Use dollar quoting around your fiction body I'd double up on the
single quotes around the dash

  Sent from my iPhone

On Feb 20, 2009, at 8:14 AM, Eus <eus@member.fsf.org> wrote:

> Hi Ho!
>
> Sorry, let me revise the query a bit. I copied and pasted the
> original one from another big query.
>
> --- On Fri, 2/20/09, Eus <eus@member.fsf.org> wrote:
>
>> The following query works well:
>
> select count (*)
> from item_audit as ia
> where audit_ts >= '2008-05-30 00:00:00'
>       and audit_ts <= '2008-10-30 00:00:00'
>       and 'wst' != (select split_part(category, '-', 2)
>                     from description
>                     where split_part(category, '-', 1) = 'item'
>                           and shorthand = ia.status
>                    )
>
>> But, when I transform it into the following SQL function,
>> the function cannot be created barking:
>>
>> ERROR:  syntax error at or near "-"
>> LINE 6:        and $1 != (select split_part(category,
>> '-', 2)"
>>
>> create or replace function get_I(text, timestamp,
>> timestamp) returns bigint as
>> 'select count (*)
>> from item_audit as ia
>> where audit_ts >= $2
>>       and audit_ts <= $3
>>       and $1 != (select split_part(category, '-',
>> 2)
>>                  from description
>>                  where split_part(category, '-',
>> 1) = 'item'
>>                        and shorthand = ia.status
>>                 )
>> ' language sql;
>>
>> What's wrong?
>>
>> Thank you.
>
> Best regards,
> Eus (FSF member #4445)
>
> In this digital era, where computing technology is pervasive, your
> freedom depends on the software controlling those computing devices.
>
> Join free software movement today! It is free as in freedom, not as
> in free beer!
>
> Join: http://www.fsf.org/jf?referrer=4445
>
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

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

Предыдущее
От: Eus
Дата:
Сообщение: Re: Why I cannot call a function from within an SQL function?
Следующее
От: Eus
Дата:
Сообщение: Re: Why I cannot call a function from within an SQL function?