Re: User date_trunc function in plpgsql function - Mailing list pgsql-general

From Scott Lamb
Subject Re: User date_trunc function in plpgsql function
Date
Msg-id 3DEE2573.3000404@slamb.org
Whole thread Raw
In response to User date_trunc function in plpgsql function  ("annachau" <annachau@hongkong.com>)
List 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


pgsql-general by date:

Previous
From: "annachau"
Date:
Subject: User date_trunc function in plpgsql function
Next
From: Ericson Smith
Date:
Subject: Re: Efficient Boolean Storage