Re: Adding flexibilty to queries - Mailing list pgsql-general

From Alan Carbutt
Subject Re: Adding flexibilty to queries
Date
Msg-id 1080224670.11679.2.camel@x.adams.edu
Whole thread Raw
In response to Re: Adding flexibilty to queries  (Bill Moran <wmoran@potentialtech.com>)
List pgsql-general
Thanks, Bill.  I'll give it a try.

++alan

On Thu, 2004-03-25 at 06:01, Bill Moran wrote:
> 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 ...
--
Alan Carbutt
Systems Administrator/Programmer
Adams State College
719-587-7741
arcarbut@adams.edu

Attachment

pgsql-general by date:

Previous
From:
Date:
Subject: Re: Solaris ecpg program doesn't work - pulling my hair
Next
From: Rob Hoopman
Date:
Subject: Re: self referencing tables/ nested sets etc...