pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sugandha Shah <Sugandhas@cybage.com>
To: Richard Huxton <dev@archonet.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Few Queries
Date: Mon, 19 Aug 2002 12:59:47 +0530
Message-ID: <099401c24752$327ae380$2005a8c0@cybage.com> (raw)
References: <01b301c24352$12570fb0$2005a8c0@cybage.com>
	<200208140702.g7E72Cd05129@janning.planwerk6.local>
	<027601c2438e$3a6304a0$2005a8c0@cybage.com>
	<200208141434.16778.dev@archonet.com>

Hello Richard,

I'm really thankful to you. It worked. Somehow I wasn't getting it to work.

This line did the trick.

    set_time := current_date() - (var_history_age_limit::text || ''  days
'')::interval;


Regards,
-Sugandha

----- Original Message -----
From: "Richard Huxton" <dev@archonet.com>
To: "Sugandha Shah" <Sugandhas@cybage.com>; "Janning Vygen" <vygen@gmx.de>
Cc: <pgsql-sql@postgresql.org>
Sent: Wednesday, August 14, 2002 7:04 PM
Subject: Re: [SQL] Few Queries


On Wednesday 14 Aug 2002 1:29 pm, Sugandha Shah wrote:
> Hi ,
>
> No luck  . Even with Select Into . Please if any body has faced similar
> problem and knows a solution.

You don't need select into here - the sample below deletes everything older
than one day. You should be able to adapt it to your needs. Your example had
a + rather than a - which would delete things in the future, that might have
been what you intended, or it might not.

The RAISE NOTICE line prints a useful debug value. I like to scatter these
around while I'm testing.

CREATE FUNCTION del_old_history() RETURNS int4 AS '
DECLARE
   var_history_age_limit int4;
   set_time    timestamp;
BEGIN
    var_history_age_limit:=1;
    set_time := current_date() - (var_history_age_limit::text || ''  days
'')::interval;
    RAISE NOTICE ''set time = %'',set_time;
    delete from history where complete_time <= set_time;

    return var_history_age_limit;
END;'
LANGUAGE 'plpgsql';

-- Richard Huxton

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org





view thread (7+ messages)

Message-ID: <099401c24752$327ae380$2005a8c0@cybage.com>
Permalink:  ../099401c24752$327ae380$2005a8c0@cybage.com/
Also on:    postgresql.org/message-id/099401c24752$327ae380$2005a8c0@cybage.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: Sugandhas@cybage.com, dev@archonet.com
  Subject: Re: Few Queries
  In-Reply-To: <099401c24752$327ae380$2005a8c0@cybage.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox