Re: passing parameters to views (or alternative methods)

From: "Henshall, Stuart - WCP" <SHenshall(at)westcountrypublications(dot)co(dot)uk>
To: 'Andrew Sher' <acs974(at)hotmail(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: passing parameters to views (or alternative methods)
Date: 2002-08-02 13:55:52
Message-ID: E2870D8CE1CCD311BAF50008C71EDE8E01F7494E@MAIL_EXCHANGE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Something like:
CREATE VIEW vw AS SELECT t1.id,t1.fld,t2.fld AS fld2 FROM t1,t2 WHERE
t1.id=t2.id;
CREATE RULE vw_upt AS ON UPDATE TO vw DO INSTEAD
(
UPDATE t1 SET t1.fld=NEW.fld WHERE id=OLD.id;
UPDATE t2 SET t2.fld=NEW.fld2 WHERE id=OLD.id;
);
Should create an updateable view.
Just do SELECT * FROM vw WHERE id=6; to select from it.
hth,
- Stuart

> -----Original Message-----
> From: Andrew Sher [mailto:acs974(at)hotmail(dot)com]
> Sent: 01 August 2002 17:24
> To: pgsql-novice(at)postgresql(dot)org
> Subject: [NOVICE] passing parameters to views (or alternative
> methods)?
>
>
> Hi,
>
> I'm new to the world of postgres and have a question which I've been
> struggling with. I'm developing an application using visual
> basic as the
> front end and I'm attempting to base a form on a query that
> produces one
> record from two joined tables, producing 8 total fields (4
> from each table).
> The record is selected based on an ID number input earlier,
> producing a
> similar query to something like (assuming the id number was 6):
>
> select table1.ID, table1.field2, table2.ID, table2.field2
> from table1,
> table2 where table2.ID=table1.ID and table1.ID = 6).
>
> Ideally, the user is then able to enter data into each field
> and have the
> new data updated to the proper underlying fields. Because
> updatable joins
> aren't supported, I was attempting to create a view that
> served the same
> purpose. The problem I am running into is I don't know how to
> limit the view
> to the one record I am trying to select via the ID number,
> which changes
> each time the program is run. In other words, I want to use
> the same view
> but be able to pass to it the ID number of the one record I
> want it to
> return. I was wondering if this is possible via views, and,
> if not, are
> there alternative ways to accomplish the task?
>
> Thanks.
>
> _________________________________________________________________
> MSN Photos is the easiest way to share and print your photos:
> http://photos.msn.com/support/worldwide.aspx
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>

Browse pgsql-novice by date

  From Date Subject
Next Message Henshall, Stuart - WCP 2002-08-02 14:01:16 Re: total newbie question: windows download (binary)
Previous Message Ken Corey 2002-08-02 10:23:26 Re: please need help: alpha numeric sorting