pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Garrett Murphy <gmurphy@lawlogix.com>
To: pgsql-sql@postgresql.org
Subject: Re: Trigger on select :-(
Date: Thu, 11 Mar 2010 11:33:59 -0500
Message-ID: <076DC33A3D38CE4BBC64D35DDD9DE70C0A283D04@mse4be2.mse4.exchange.ms> (raw)
In-Reply-To: <CMEFJOLLJJDJKKLGEJJMOELBDDAA.ray@madigans.org>
References: <CMEFJOLLJJDJKKLGEJJMOELBDDAA.ray@madigans.org>

Are you able to set up a SELECT query to get the result you want?  If
you are, it's as simple as putting "CREATE VIEW viewname AS ", followed
by your query.

Garrett Murphy

_____________________________________________
From: pgsql-sql-owner@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Ray Madigan
Sent: Monday, March 01, 2010 7:11 PM
To: pgsql-sql@postgresql.org
Subject: [SQL] Trigger on select :-(


What I want is to have a trigger on select, but since I have searched
the archives I know that is not possible.  I also read that view rules
is the technology is whats available.  Having never used views before I
can't seem to get my mind to figure out what I need to do to solve my
problem.

I have a table that defines a key that I will use in another table in a
list of items defined in the previous table.

The tables are

CREATE TABLE Foo ( INTEGER key not null primary key,
                                  ...  characteristics for the Foo item
);

CREATE TABLE Catalog ( INTEGER FooKey FOREIGN KEY,
                                        ... other catalog data );

The catalog will have rows that reference the elements in the Foo table.

I also have another table that references the Foo table

CREATE TABLE ToDo ( INTEGER FooKey FOREIGN KEY,
                                    ... other ToDo information.

What I want to do is when I do a SELECT on the Catalog and deliver the
result to the user, I want to check to see if the FooKey is in the users
ToDo table and set the value of a column isToDo to true or false
depending on if the FooKey exists in the ToDo table for the user.  If I
were building a table I would use a trigger and select on the row in the
ToDo table.

Please, all I want is an idea where to start, what I should read and I
will figure out how to do it.

Thanks in advance. << File: ATT4311246.txt >> 

view thread (6+ messages)  latest in thread

Message-ID: <076DC33A3D38CE4BBC64D35DDD9DE70C0A283D04@mse4be2.mse4.exchange.ms>
Permalink:  ../076DC33A3D38CE4BBC64D35DDD9DE70C0A283D04@mse4be2.mse4.exchange.ms/
Also on:    postgresql.org/message-id/076DC33A3D38CE4BBC64D35DDD9DE70C0A283D04@mse4be2.mse4.exchange.ms

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gmurphy@lawlogix.com
  Subject: Re: Trigger on select :-(
  In-Reply-To: <076DC33A3D38CE4BBC64D35DDD9DE70C0A283D04@mse4be2.mse4.exchange.ms>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox