Re: [SQL] question on passing parameter in sql query
От | Chad Wagner |
---|---|
Тема | Re: [SQL] question on passing parameter in sql query |
Дата | |
Msg-id | 81961ff50702071756j62247349k7062839ec44901a5@mail.gmail.com обсуждение исходный текст |
Ответ на | question on passing parameter in sql query ("Karthikeyan Sundaram" <skarthi98@hotmail.com>) |
Список | pgsql-admin |
On 2/7/07, Karthikeyan Sundaram <skarthi98@hotmail.com> wrote:
It can be done, but it is a bit "different" and this method is UNIX dependent:
test=# create table data (x integer not null primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "data_pkey" for table "data"
CREATE TABLE
test=# insert into data values (1),(2),(3),(4);
INSERT 0 4
test=# \set foo `head -1`
3
test=# \echo :foo
3
test=# select * from data where x = :foo;
x
---
3
(1 row)
I don't believe it automatically prompts the way Oracle does. It would be nice if there was a built-in "\prompt [VARIABLE] [TEXT]".
--
Chad
http://www.postgresqlforums.com/
I don't want to compare with Oracle and postgres. But I have a situation.
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 dependent:
test=# create table data (x integer not null primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "data_pkey" for table "data"
CREATE TABLE
test=# insert into data values (1),(2),(3),(4);
INSERT 0 4
test=# \set foo `head -1`
3
test=# \echo :foo
3
test=# select * from data where x = :foo;
x
---
3
(1 row)
I don't believe it automatically prompts the way Oracle does. It would be nice if there was a built-in "\prompt [VARIABLE] [TEXT]".
--
Chad
http://www.postgresqlforums.com/
В списке pgsql-admin по дате отправления: