Re: parameterized views?

From: Joe Conway <mail(at)joeconway(dot)com>
To: Linn Kubler <LKubler(at)ecw(dot)org>
Cc: PostgreSQL Mailing Lists-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: parameterized views?
Date: 2002-09-03 04:32:04
Message-ID: 3D743B44.2080601@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Linn Kubler wrote:
> Hi,
>
> Is it possible to have parameterized views? Guess I'm thinking of
> something like a posiitonal parameter in a view. If it is possible I'd
> sure appreciate an example.
>

In 7.3 (starting beta this week) you can return sets (rows and columns)
from table functions. For example:

test=# create table foo(f1 int, f2 text, f3 text[], primary key (f1,f2));
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
'foo_pkey' for table 'foo'
CREATE TABLE
test=# insert into foo values(0,'a','{"a0","b0","c0"}');
INSERT 664851 1
test=# insert into foo values(1,'b','{"a1","b1","c1"}');
INSERT 664852 1
test=# insert into foo values(2,'c','{"a2","b2","c2"}');
INSERT 664853 1
test=# create or replace function get_foo(int) returns setof foo as
'select * from foo where f1 > $1' language sql;
CREATE FUNCTION
test=# select * from get_foo(0);
f1 | f2 | f3
----+----+------------
1 | b | {a1,b1,c1}
2 | c | {a2,b2,c2}
(2 rows)

Is this what you're looking for?

HTH,

Joe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ben-Nes Michael 2002-09-03 08:11:57 Re: php
Previous Message Linn Kubler 2002-09-03 03:25:47 parameterized views?