Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DC0FB475CEF for ; Wed, 14 Aug 2002 09:45:02 -0400 (EDT) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by postgresql.org (Postfix) with ESMTP id 5984B475C65 for ; Wed, 14 Aug 2002 09:45:02 -0400 (EDT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-35.mail.demon.net with esmtp (Exim 3.36 #2) id 17eySO-0005rP-0U; Wed, 14 Aug 2002 14:45:05 +0100 Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id F23FF140BB; Wed, 14 Aug 2002 14:34:18 +0100 (BST) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: "Sugandha Shah" , "Janning Vygen" Subject: Re: Few Queries Date: Wed, 14 Aug 2002 14:34:16 +0100 User-Agent: KMail/1.4.1 Cc: References: <01b301c24352$12570fb0$2005a8c0@cybage.com> <200208140702.g7E72Cd05129@janning.planwerk6.local> <027601c2438e$3a6304a0$2005a8c0@cybage.com> In-Reply-To: <027601c2438e$3a6304a0$2005a8c0@cybage.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200208141434.16778.dev@archonet.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/227 X-Sequence-Number: 9073 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= =20 than one day. You should be able to adapt it to your needs. Your example ha= d=20 a + rather than a - which would delete things in the future, that might hav= e=20 been what you intended, or it might not. The RAISE NOTICE line prints a useful debug value. I like to scatter these= =20 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:=3D1; set_time :=3D current_date() - (var_history_age_limit::text || '' days= =20 '')::interval; RAISE NOTICE ''set time =3D %'',set_time; delete from history where complete_time <=3D set_time; return var_history_age_limit; END;' LANGUAGE 'plpgsql'; -- Richard Huxton