Re: simple trigger problem ?

From: Mark D Powell <markp7832_at_my-deja.com>
Date: 2000/05/08
Message-ID: <8f783u$oh$1_at_nnrp1.deja.com>#1/1


In article <pjBR4.171454$uF1.379377_at_afrodite.telenet-ops.be>,   "norab" <norab_at_digibel.org> wrote:
> > On the other hand if the
> > customer table only has a pointer to the address table then the
 change
> > of the address will not require any change to A. In this case if
 you
> > want to know who is affected by the address change just build an
 index
> > on the FK address column in A and query on it.
>
> This is the case.
> and indeed i want to know who is affected by the adress change.
> but i dont know how i have to do that
> and i have no experience with building indexes :/
>
> is it possible to describe what i have to do exactly ?
>
> it would help me ALOT
> tnx man
>
> norab.
>
To build an index it is just:
create index owner.index_name on owner.table_name (column_list);

The optimizer will determine if it want to use the index to aid performance while solving a query. You can code a query against the customer table in the update trigger on the address table using the address_key to see if any rows are using it.

select count(*) from table_a where address_id = :old.address_id;

Select count always returns a value, 0 would mean no rows reference this address and a count > 0 would tell you how many rows. You could retrieve the rows or their keys when they exist. The question is what you do with them, but you seem to have an idea what you want to accomplish. Good luck.

--
Mark D. Powell  -- The only advice that counts is the advice that
 you follow so follow your own advice --


Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Mon May 08 2000 - 00:00:00 CEST

Original text of this message