Re: substitute variable in sql? - Mailing list pgsql-general

From Johnson, Shaunn
Subject Re: substitute variable in sql?
Date
Msg-id 73309C2FDD95D11192E60008C7B1D5BB04C74133@snt452.corp.bcbsm.com
Whole thread Raw
In response to substitute variable in sql?  ("Johnson, Shaunn" <SJohnson6@bcbsm.com>)
Responses Re: substitute variable in sql?  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-general

--thanks for the reply

--i just have an sql script that i launch
--by hand (psql -U <user> -d <database> -f ./<script>)

--the date is a rolling date which is supposed to
--change every 3 months.  and as variable 1 is moved
--up every month, so should variable 2 move up every
--month.

--the result is var1 and var2 should always be
--3 months apart every month (or, every time i
--run the script).

--now i *could* run psql from a shell ... can i
--substitute a variable and just stick it in place
--when i run the sql script?

--thanks again!

-X

-----Original Message-----
From: Doug McNaught [mailto:doug@mcnaught.org]

"Johnson, Shaunn" <SJohnson6@bcbsm.com> writes:

> Running PostgreSQL 7.2.1 on RedHat Linux 7.2: 

> I have a query where I have to replace the
> date parameter each time I run the query.

> Is there a way to substitute just the date
> parameter in the sql without having to
> edit the script, re-run and edit again?

There are loads of ways to do this.  What client language are you
using?  Are you running 'psql' from a shell script?

-Doug

pgsql-general by date:

Previous
From: Doug McNaught
Date:
Subject: Re: substitute variable in sql?
Next
From: Bruno Wolff III
Date:
Subject: Re: substitute variable in sql?