Re: Plpgsql - Custom fields Postgres 9.5

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Lucas Possamai <drum(dot)lucas(at)gmail(dot)com>
Cc: Patrick B <patrickbakerbr(at)gmail(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, rob stone <floriparob(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Plpgsql - Custom fields Postgres 9.5
Date: 2016-12-15 02:08:09
Message-ID: 2e970123-8c68-1cab-d74e-08609b16404b@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12/14/2016 05:56 PM, Lucas Possamai wrote:
> ERROR: column "date_start" does not exist
>
>
> Patrick
>
>
> Patrick*** - trying on SQL fiddle i got that error when executing what
> Adrian suggested.
>

Yeah, it was my turn not to be paying attention. It has been that sort
of day and I guess I could not expect the end of day to get better.

So something that might actually work;

CREATE or REPLACE FUNCTION l_extract(date_start date, date_end date))

RETURNS void AS $$

begin

execute '

COPY

(

SELECT

uuid,

clientid,

*

FROM

logging

WHERE

logtime

BETWEEN

$1

AND

$2

)

TO ''/var/lib/postgresql/'|| date_start ||'_logs.csv'''
USING date_start, date_end;

end

$$ language 'plpgsql';

select l_extract('20161115'::date, '20161215'::date);

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dylan Luong 2016-12-15 03:06:30 pgAudit_Analyze - parse error in pgaudit_analyze.log
Previous Message Patrick B 2016-12-15 01:57:19 Re: Plpgsql - Custom fields Postgres 9.5