From: | Ruben Gouveia <rubes7202(at)gmail(dot)com> |
---|---|
To: | Bricklen Anderson <banderson(at)presinet(dot)com> |
Cc: | pgsql-sql <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Function Syntax involving pipes and ' marks? |
Date: | 2008-09-10 18:38:34 |
Message-ID: | B63201FF-5D5C-4937-AFF6-F2335F6B9B11@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Is that more expensive to run than just useing a bunch of ticks?
Sent from Apple iPhone 3G
On Sep 10, 2008, at 11:24 AM, Bricklen Anderson
<banderson(at)presinet(dot)com> wrote:
> Ruben Gouveia wrote:
>> v_where varchar(256) := 'where m.jb_date < '||p_date + integer
>> '1'||
>> ' and m.jb_date >='||p_date||'';
>
> Try wrapping your p_date in a quote_literal like
> ...
> 'where m.jb_date < '||quote_literal(p_date+INTEGER '1')||' and ...
>
> eg.
>
> CREATE OR REPLACE FUNCTION fcn_job(p_date date, p_type
> varchar,p_jobid numeric) RETURNS numeric AS $$
> DECLARE
> v_job numeric := 0;
> v_stmt varchar(1024);
> v_where varchar(256) := 'where m.jb_date < '||
> quote_literal(p_date + integer '1')||' and m.jb_date >='||
> quote_literal(p_date);
> BEGIN
> v_stmt := fcn_gen_statement(p_type, v_where, p_newonly);
> execute v_stmt into v_job;
> RAISE NOTICE 'sql looks like this: % . ',v_stmt;
> return v_job;
> END;
> $$ LANGUAGE plpgsql;
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2008-09-10 18:45:55 | Re: Function Syntax involving pipes and ' marks? |
Previous Message | Bricklen Anderson | 2008-09-10 18:36:41 | Re: Function Syntax involving pipes and ' marks? |