Re: Adding flexibilty to queries

From: Bill Moran <wmoran(at)potentialtech(dot)com>
To: arcarbut(at)adams(dot)edu
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Adding flexibilty to queries
Date: 2004-03-25 13:01:44
Message-ID: 4062D838.10400@potentialtech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alan Carbutt wrote:
> Hi all,
>
> I have a question regarding psql. As I am more familiar with oracle I
> can write the following select and make it rather flexible:
> select name
> from name_table
> where person_id = &id;
> The &id portion is what I am looking for in PostgreSQL. Basically when
> running this query, the person running the query is prompted to supply a
> value. What is the equivalent in postgres?

Doesn't seem like anyone else has answered this ...

I think you can accomplish what you want with stored functions. For
example:

create function get_name(INT)
returns <type of name column>
as '
select name from name_table where person_id = $1;
' language sql;

The user can then call this by:
select get_name(<name id>);

Don't know if that's what you're looking for or not ...

--
Bill Moran
Potential Technologies
http://www.potentialtech.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jan Wieck 2004-03-25 13:05:05 Re: subversion vs cvs (Was: Re: linked list rewrite)
Previous Message Nilton Yudiro Ikezire 2004-03-25 12:51:49 Compiling