pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedquestion on passing parameter in sql query
2+ messages / 2 participants
[nested] [flat]
* question on passing parameter in sql query
@ 2007-02-08 00:49 Karthikeyan Sundaram <skarthi98@hotmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Karthikeyan Sundaram @ 2007-02-08 00:49 UTC (permalink / raw)
To: pgsql-admin@postgresql.org; pgsql-sql
Hi,
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 ?
Regards
skarthi
_________________________________________________________________
Invite your Hotmail contacts to join your friends list with Windows Live
Spaces
http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.a...
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [SQL] question on passing parameter in sql query
@ 2007-02-08 01:56 Chad Wagner <chad.wagner@gmail.com>
parent: Karthikeyan Sundaram <skarthi98@hotmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: Chad Wagner @ 2007-02-08 01:56 UTC (permalink / raw)
To: Karthikeyan Sundaram <skarthi98@hotmail.com>; +Cc: pgsql-admin@postgresql.org; pgsql-sql
On 2/7/07, Karthikeyan Sundaram <skarthi98@hotmail.com> wrote:
>
> 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/
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2007-02-08 01:56 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-02-08 00:49 question on passing parameter in sql query Karthikeyan Sundaram <skarthi98@hotmail.com>
2007-02-08 01:56 ` Chad Wagner <chad.wagner@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox