Re: indexing date_part

From: Jeff Davis <jdavis-pgsql(at)empires(dot)org>
To: DEV <dev(at)umpa-us(dot)com>
Cc: PgSQL General List <pgsql-general(at)postgresql(dot)org>
Subject: Re: indexing date_part
Date: 2005-02-28 20:15:14
Message-ID: 1109621714.4089.277.camel@jeff
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In this case you just have a syntax error in your function. You have
tried to use a single-quoted string inside of a single-quoted string.
Escape the single quotes by writing "''" instead of "'" inside the
function definition.

For example:

CREATE FUNCTION month_idxable(date) returns date AS 'SELECT
date_part(''month'', date) from mchistw' LANGUAGE 'SQL' WITH
(iscachable);

After creating the function, just create the functional index and you
should be on the right track.

Regards,
Jeff Davis

On Mon, 2005-02-28 at 14:35 -0500, DEV wrote:
> Hello all,
>
>
>
> I am interested in setting up an index with a date_part as part of it…
> From what I have been able to find I need to write a function that
> will return the date_part that I want I have tried
> CREATE FUNCTION month_idxable(date) returns date AS 'SELECT
> date_part('month', date) from mchistw' LANGUAGE 'SQL' WITH
> (iscachable);
>
> And I get: ERROR: parser: parse error at or near "month" at character
> 72
>
>
>
> So what am I doing wrong and how would I include the function into an
> index?
>
>
>
> Thank you all for all of your help!
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John DeSoi 2005-02-28 20:17:29 Re: PostgreSQL 8 compiling for Windows
Previous Message bill 2005-02-28 19:46:16 Clay Shirky observation regarding MySQL