scope quirk in copy in function - Mailing list pgsql-general

From Scott Ribe
Subject scope quirk in copy in function
Date
Msg-id 84BAAF8D-20EF-451A-A055-17BBC78CD864@elevated-dev.com
Whole thread Raw
Responses Re: scope quirk in copy in function
List pgsql-general
create or replace function archive_some_stuff() returns void as $$
declare cutoff timestamptz;
begin
  cutoff := now() - '1 day'::interval;
  copy (select * from log where end_when < cutoff) to ...
  ...

Gives me an error that there is column named cutoff. (Other uses of cutoff in queries not inside a copy, iow the delete
fromcommands, work.) 

Is there any alternative to just duplicating the now() expression inside every copy?

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice







pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: xml
Next
From: Tom Lane
Date:
Subject: Re: xml