Re: User date_trunc function in plpgsql function

From: Scott Lamb <slamb(at)slamb(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: User date_trunc function in plpgsql function
Date: 2002-12-04 15:55:31
Message-ID: 3DEE2573.3000404@slamb.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

annachau wrote:
> 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 '' ||;

You're quoting something inside a quoted string (str_QuerySql) inside
another quoted string (the PL/pgSQL function). You need to escape twice.
''''

Scott

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Felipe Schnack 2002-12-04 16:01:22 Re: Efficient Boolean Storage
Previous Message pginfo 2002-12-04 15:45:00 Slow delete by table with reference to him slef.