Re: Adding flexibilty to queries

Поиск
Список
Период
Сортировка
От Bill Moran
Тема Re: Adding flexibilty to queries
Дата
Msg-id 4062D838.10400@potentialtech.com
обсуждение исходный текст
Ответ на Adding flexibilty to queries  (Alan Carbutt <arcarbut@adams.edu>)
Ответы Re: Adding flexibilty to queries  (Alan Carbutt <arcarbut@adams.edu>)
Re: Adding flexibilty to queries  (Jeff Eckermann <jeff_eckermann@yahoo.com>)
Список 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


В списке pgsql-general по дате отправления:

Предыдущее
От: Manfred Koizar
Дата:
Сообщение: Re: self referencing tables/ nested sets etc...
Следующее
От: Jan Wieck
Дата:
Сообщение: Re: pg_dump "what if?"