BROBLEM IN BETWEEN QUERY (plpgsql) - Mailing list pgsql-sql

From Anoop G
Subject BROBLEM IN BETWEEN QUERY (plpgsql)
Date
Msg-id 1a027d210804030324x263be097x8be6f2fea6ca183d@mail.gmail.com
Whole thread Raw
Responses Re: BROBLEM IN BETWEEN QUERY (plpgsql)
List pgsql-sql
hai all,<br /><br />    I have  a  plpgsql function and I am using   postgresl 8.1.9<br /><br /><br />CREATE OR REPLACE
FUNCTIONget_vehicle_id(INT) RETURNS SETOF RECORD AS $BODY$<br />DECLARE<br /><br />    r RECORD;<br />        int_day 
ALIASFOR $1;<br /><br />BEGIN<br /><br />     FOR r in SELECT fk_bint_old_vehicle_number AS vehicle_id<br />     FROM
tbl_rac_vehicle_replacement<br/>     WHERE dat_replacement BETWEEN now() - interval '% day',int_day <br />     AND
now()LOOP<br />              <br />             RETURN NEXT r;<br />     END LOOP;<br />     <br />     RETURN;<br
/>END<br/>$BODY$ LANGUAGE 'plpgsql';<br /><br /><br />   But i cant craete the function  The error message is:<br /><br
/><br/>ERROR:  syntax error at or near "," at character 137<br /> QUERY:   SELECT fk_bint_old_vehicle_number AS
vehicle_idFROM tbl_rac_vehicle_replacement WHERE dat_replacement BETWEEN now() - interval '% day', $1  AND now()<br
/>CONTEXT: SQL statement in PL/PgSQL function "test" near line 11<br /> LINE 1: ...E dat_replacement BETWEEN now() -
interval'% day', $1  AND ...<br /><br /><br /><br /><br />The problem line is  BETWEEN now() - interval '% day', $1 
ANDnow()<br /><br />I want to select  dat_replacement  between now ()  and now - 5 dyas or now -7 days like that  i
wantto pass the integer value as argument to the function.<br /><br /><br />I also tried like this  WHERE
dat_replacementBETWEEN now() - interval int_day day <br />     AND now(),but it also failed.<br /><br /><br />    
Pleasehelp me .<br /><br />  regards:<br />              Anoop<br /><br />              <br /><br /><br /><br /><br
/><br/>    <br /><br />   <br /><br /><br />                  <br /> 

pgsql-sql by date:

Previous
From: Ivan Sergio Borgonovo
Date:
Subject: Re: update with join
Next
From: "A. Kretschmer"
Date:
Subject: Re: BROBLEM IN BETWEEN QUERY (plpgsql)