User date_trunc function in plpgsql function

From: "annachau" <annachau(at)hongkong(dot)com>
To: "Pgsql - General" <pgsql-general(at)postgresql(dot)org>
Subject: User date_trunc function in plpgsql function
Date: 2002-12-04 15:41:27
Message-ID: 1039016487.25828.annachau@hongkong.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

How can I use datetrunc in plpgsql function with quote 'day'?

e.g.
str_QuerySql = ''SELECT 1 FROM ot_Source WHERE source_code = ''
|| quote_literal(str_Source ) ||
'' and status = ''
|| quote_literal(str_ACT) ||
'' and (current_date - date_trunc('day', effective_date) ) >= 0 '' ||;
open cursor_source FOR EXECUTE str_QuerySql;
FETCH cursor_source INTO int_RtnVal;

I got error on date_trunc('day', effective_date) because the 'day'. How can I quote
it? I have tried quote_literal() function like this:
str_day = ''day''
'' and (current_date - date_trunc('' || quote(str_day) || '', effective_date) ) >= 0 '' ||;
but show "attribute day not found"

Please help.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message pginfo 2002-12-04 15:45:00 Slow delete by table with reference to him slef.
Previous Message Richard Huxton 2002-12-04 15:11:09 Re: Efficient Boolean Storage