Re: Not sure how to approach this
From: Andy Hardy <junkmail_at_[127.0.0.1]>
Date: Sun, 03 Sep 2006 23:54:58 +0100
Message-ID: <44fb5d43$0$3620$ed2e19e4_at_ptn-nntp-reader04.plus.net>
>>> I have 3 tables.
>>> 1) books
>>> 2) publishers
>>> 3) subjects
>>>
>>> I *think* I need to use a trigger but not sure.
>>> I've loaded up publishers with distinct publisher from books and
>>> subjects from distinct subject from books. Now I want to set
>>> *something* up so that if I add a new row to "books" a check will be
>>> made on publishers and subjects to see if something new is being added
>>> and then add a row if this is the case.
>>>
>>> Something like
>>>
>>> On_New_Book
>>> insert into publishers
>>> select publisher from book
>>> where book.publisher not in (select publisher from book)
>>> insert into subjects
>>> select subject from book
>>> where book.subject not in (select subject from book)
>>>
>>> I don't know how close or far away I am. I'm not even sure if a
>>> "trigger" is what I need here.
>>>
Views are virtual, think of them as stored queries. When queried, they derive their data from the tables on which they are based. Received on Mon Sep 04 2006 - 00:54:58 CEST
Date: Sun, 03 Sep 2006 23:54:58 +0100
Message-ID: <44fb5d43$0$3620$ed2e19e4_at_ptn-nntp-reader04.plus.net>
jctown_at_nb.sympatico.ca wrote:
> Andy Hardy wrote: >> jctown_at_nb.sympatico.ca wrote:
>>> I have 3 tables.
>>> 1) books
>>> 2) publishers
>>> 3) subjects
>>>
>>> I *think* I need to use a trigger but not sure.
>>> I've loaded up publishers with distinct publisher from books and
>>> subjects from distinct subject from books. Now I want to set
>>> *something* up so that if I add a new row to "books" a check will be
>>> made on publishers and subjects to see if something new is being added
>>> and then add a row if this is the case.
>>>
>>> Something like
>>>
>>> On_New_Book
>>> insert into publishers
>>> select publisher from book
>>> where book.publisher not in (select publisher from book)
>>> insert into subjects
>>> select subject from book
>>> where book.subject not in (select subject from book)
>>>
>>> I don't know how close or far away I am. I'm not even sure if a
>>> "trigger" is what I need here.
>>>
>> You want to be able to see distinct publishers and distinct subjects >> based on information from your books? If so, sounds like you actually >> want to use views instead of tables for your 'publishers' and 'subjects'. > [Quoted] > That worked. So tell me something... does Oracle actually keep the > "view" stored physically like it does a table or is it more virtual? >
Views are virtual, think of them as stored queries. When queried, they derive their data from the tables on which they are based. Received on Mon Sep 04 2006 - 00:54:58 CEST