Re: using vars in scripts

From: "LLC" <kevin(at)kevinkempterllc(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: using vars in scripts
Date: 2006-06-26 22:01:32
Message-ID: 1151359292.v2.fusewebmail-164106@f
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Postgres offers several methods. I'll assume you're running Linux/bash, if not try and convert the following to whatever OS/shell you're using:

# Bash script 1 using a here document:

tabname='mytab'
tabcol='username'


psql >;dbname> >;>;EOF
select $tabcol from $tabname;
EOF!


# Bash script 2 - using echo:

tabname='mytab'
tabcol='username'

echo "select $tabcol from $tabname" | psql >;dbname>

There are many variations on these examples, hope this helps...

----- Original Message -----

Subject: [NOVICE] using vars in scripts

From: "pablo sebastian rodriguez" >;psrodriguez(at)gmail(dot)com>

Date: Fri, June 23, 2006 18:37

hi,

i know this is silly, but i can't find the way...

with mssql i can do this:

declare @my_var varchar(20) ;
set @my_var = 'something' ;
select @my_var ;

with mysql it's even easier:

set @my_var = 'something' ;
select @my_var ;


but, with postgre ? i don't know how to do that...

Browse pgsql-novice by date

  From Date Subject
Next Message operationsengineer1 2006-06-26 22:20:34 Re: Table Merge Successful, Primary Keys Missing
Previous Message Tom Lane 2006-06-26 21:04:48 Re: Variable array sizes with PQexecParams