Thread: Setting global parameter in Postgres 8.3

Setting global parameter in Postgres 8.3

From
Date:

Hi All,

 

Is there any way we can set the global parameter in Postgres 8.3?

As I have a sql script which need to accept some parameter at run time. For example I have sql script for creating tablespaces called “create_tablespace.sql”

 

Inside the sql script I have the following statements

 

CREATE TABLESPACE bank_index_tbsp OWNER bank LOCATION '$drive/data/bank/index_tbsp';

CREATE TABLESPACE bank_master_tbsp OWNER bank LOCATION ‘$drive/data/bank/master_tbsp';

CREATE TABLESPACE bank_static_tbsp OWNER bank LOCATION ‘$drive /data/bank/static_tbsp';

 

I need to replace the $drive with a absoulte location in order to create the tablespaces at run time.So is there any way I can pass parameter to sql file at the time of execuitng it or is there any way I can set a global parameter which will repalce the $drive similar to the way postregs converts or maps the $libdir parameter to the absolute path of the “Lib” location of postgres.

 

Any help and suggestion will be really helpful.

 

Many thanks in advance

 

 

 

 

Re: Setting global parameter in Postgres 8.3

From
"A. Kretschmer"
Date:
In response to A.Bhattacharya@sungard.com :
> CREATE TABLESPACE bank_master_tbsp OWNER bank LOCATION ?$drive/data/bank/
> master_tbsp';
>
> CREATE TABLESPACE bank_static_tbsp OWNER bank LOCATION ?$drive /data/bank/
> static_tbsp';
>
>
>
> I need to replace the $drive with a absoulte location in order to create the
> tablespaces at run time.So is there any way I can pass parameter to sql file at
> the time of execuitng it or is there any way I can set a global parameter which

No. AFAIK.


> will repalce the $drive similar to the way postregs converts or maps the
> $libdir parameter to the absolute path of the ?Lib? location of postgres.

Create a function for that ...


Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

Re: Setting global parameter in Postgres 8.3

From
Scott Mead
Date:
On Thu, Jan 14, 2010 at 11:10 AM, A. Kretschmer <andreas.kretschmer@schollglas.com> wrote:
In response to A.Bhattacharya@sungard.com :
> CREATE TABLESPACE bank_master_tbsp OWNER bank LOCATION ?$drive/data/bank/
> master_tbsp';
>
> CREATE TABLESPACE bank_static_tbsp OWNER bank LOCATION ?$drive /data/bank/
> static_tbsp';
>
>
>
> I need to replace the $drive with a absoulte location in order to create the
> tablespaces at run time.So is there any way I can pass parameter to sql file at
> the time of execuitng it or is there any way I can set a global parameter which


  You can't do in it plain sql, but if your script is designed especially for psql, then you could use a psql variable:



--Scott