Re: create function problem

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: create function problem
Дата
Msg-id 20040319064220.W75424@megazone.bigpanda.com
обсуждение исходный текст
Ответ на create function problem  ("Thomas Leung" <thomasleung@hotmail.com>)
Список pgsql-admin
On Tue, 16 Mar 2004, Thomas Leung wrote:

> I want to index my table using the year of the date. So I create the
> following function.
>
> create function to_year(date) returns varchar as '
> declare
>   str varchar;
>   begin
>     str := to_char($1, "YYYY");
>     return str;
>   end;
> ' language 'plpgsql' with (iscachable, isstrict);
>
> But I face the problem as follow
> select to_year(current_date);
> WARNING:  Error occurred while executing PL/pgSQL functions to_year
> WARNING:  line 4 at assignment
> ERROR:  Attribute "YYYY" not found
>
> Anybody can help? Thanks.

I think you're going towant doubled single quotes (''YYYY'') not double
quotes.

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

Предыдущее
От: Bill Montgomery
Дата:
Сообщение: Re: unimplemented functions
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: SOS ---- Could you help me with postgresql.....????