dbTalk Databases Forums  

Re: [SQL] Trigger on select :-(

mailing.database.pgsql-sql mailing.database.pgsql-sql


Discuss Re: [SQL] Trigger on select :-( in the mailing.database.pgsql-sql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Garrett Murphy
 
Posts: n/a

Default Re: [SQL] Trigger on select :-( - 03-11-2010 , 10:33 AM






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 (AT) postgresql (DOT) org
[mailtogsql-sql-owner (AT) postgresql (DOT) org] On Behalf Of Ray Madigan
Sent: Monday, March 01, 2010 7:11 PM
To: pgsql-sql (AT) postgresql (DOT) 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 >>

Reply With Quote
  #2  
Old   
Jaime Casanova
 
Posts: n/a

Default Re: [SQL] Trigger on select :-( - 03-12-2010 , 12:56 AM






On Mon, Mar 1, 2010 at 9:10 PM, Ray Madigan <ray (AT) madigans (DOT) org> wrote:
Quote:
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.
you should do this when inserting data (with triggers of course)

you can't use rules because a RULE ON SELECT you only can use one
SELECT, no INSERT, UPDATE nor DELETE

--
Atentamente,
Jaime Casanova
Soporte y capacitación de PostgreSQL
AsesorÃ*a y desarrollo de sistemas
Guayaquil - Ecuador
Cel. +59387171157

--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.