On 2/7/07, Karthikeyan Sundaram <skarthi98(at)hotmail(dot)com> wrote:
> I don't want to compare with Oracle and postgres. But I have a
> I am using psql command line tool supplied by postgres.
> In Oracle I can say
> select * from emp where emp_id = &1
> Oracle will ask:
> Enter a value for 1:
> If I enter 10, then Oracle will get the empid=10
> What is the equal command in postgres ?
It can be done, but it is a bit "different" and this method is UNIX
test=# create table data (x integer not null primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "data_pkey"
for table "data"
test=# insert into data values (1),(2),(3),(4);
INSERT 0 4
test=# \set foo `head -1`
test=# \echo :foo
test=# select * from data where x = :foo;
I don't believe it automatically prompts the way Oracle does. It would be
nice if there was a built-in "\prompt [VARIABLE] [TEXT]".
In response to
pgsql-admin by date
|Next:||From: Moiz Kothari||Date: 2007-02-08 05:49:22|
|Subject: Question on Fragmentations|
|Previous:||From: Jaime Casanova||Date: 2007-02-08 01:44:01|
|Subject: Re: Moving a table to another directory|
pgsql-sql by date
|Next:||From: Bryce Nesbitt||Date: 2007-02-08 07:16:12|
|Subject: Re: Seeking quick way to clone a row, but give it a new pk.|
|Previous:||From: Karthikeyan Sundaram||Date: 2007-02-08 00:49:45|
|Subject: question on passing parameter in sql query|