dbTalk Databases Forums  

Conditional Trigger

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Conditional Trigger in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #21  
Old   
mowinom@hotmail.com
 
Posts: n/a

Default Re: Conditional Trigger - 11-21-2007 , 03:43 PM






On Nov 21, 7:45 pm, Frank van Bortel <frank.van.bor... (AT) gmail (DOT) com>
wrote:
Quote:
mowi... (AT) hotmail (DOT) com wrote:
Frank's suggestion was a natural and a good one. And yes, I know about
modeling and normalization. Problem is that a pannel decided that it
be done as specified above. There are already too many tables in the
database already.

Oh no! Democracy in database design: "a panel decided..."

Just gimme back my mini's and my 911 CRT, and the days I decided
what to automate, and how and when and all users had to do was
worship me. Oh, and they could be allowed to use the product
every now and then - if I was in a good mood.

What you are doing is creating a non-scalable heap of crap,
that can simply and elegantly be resolved by normalization.

I'd demand signatures of the committee under a statement, that
no Oracle developer, DBA, or (external) consultant is ever
going to be held responsible for this... "design"
--
Regards,
Frank van Bortel

Top-posting is one way to shut me up...
Frank, you're absolutely right. In my case, however, design is done by
other people and different aspects of development by others. And
unfortunately, I'm not in a position to demand anything.



Reply With Quote
  #22  
Old   
mowinom@hotmail.com
 
Posts: n/a

Default Re: Conditional Trigger - 11-21-2007 , 04:21 PM






Hi all,

I've modified the trigger and used a cursor. It's working fairly well
now. It'll accept a second ISBN in the ISBN field only if the value of
PERIODICAL#_OWNER being entered exists in the ISBN column. What I've
notice, however is that once entered, the PERIODICAL#_OWNER attribute
accepts any value entered including nulls when updated. Any suggestion
to better this is warmly welcome and appreciated.

David, you realize that this is not a school project. So, unconcealing
the code would help, a lot.

Here the code:

CREATE OR REPLACE TRIGGER temp_test
BEFORE INSERT OR UPDATE OF ISBN ON PERIODICAL
FOR EACH ROW WHEN (new.ISBN IS NOT NULL)
DECLARE
get VARCHAR2(9);
invalid_value EXCEPTION;
valid_value EXCEPTION;

CURSOR curGet (issno VARCHAR2) IS
Select ISBN FROM PERIODICAL
Where ISBN IN
(SELECT ISBN FROM PERIODICAL
WHERE PERIODICAL# = :new.PERIODICAL#_OWNER)
FOR UPDATE OF ISBN;
BEGIN

OPEN curGet (:new.ISBN);
FETCH curGet INTO get;

IF curGet%NOTFOUND THEN
RAISE invalid_value;
ELSE
RAISE valid_value;
END IF;
CLOSE curGet;

EXCEPTION
WHEN invalid_value THEN
CLOSE curGet;
RAISE_APPLICATION_ERROR(-20070, 'ERROR>>' ||
' PERIODICAL:' ||
' For ISBN that already exists in the basen, it' ||
' must exist in periodicald to be accepted.');
WHEN valid_value THEN
CLOSE curGet;

END;

Reply With Quote
  #23  
Old   
DA Morgan
 
Posts: n/a

Default Re: Conditional Trigger - 11-22-2007 , 02:19 AM



mowinom (AT) hotmail (DOT) com wrote:
Quote:
On Nov 21, 7:45 pm, Frank van Bortel <frank.van.bor... (AT) gmail (DOT) com
wrote:
mowi... (AT) hotmail (DOT) com wrote:
Frank's suggestion was a natural and a good one. And yes, I know about
modeling and normalization. Problem is that a pannel decided that it
be done as specified above. There are already too many tables in the
database already.
Oh no! Democracy in database design: "a panel decided..."

Just gimme back my mini's and my 911 CRT, and the days I decided
what to automate, and how and when and all users had to do was
worship me. Oh, and they could be allowed to use the product
every now and then - if I was in a good mood.

What you are doing is creating a non-scalable heap of crap,
that can simply and elegantly be resolved by normalization.

I'd demand signatures of the committee under a statement, that
no Oracle developer, DBA, or (external) consultant is ever
going to be held responsible for this... "design"
--
Regards,
Frank van Bortel

Top-posting is one way to shut me up...

Frank, you're absolutely right. In my case, however, design is done by
other people and different aspects of development by others. And
unfortunately, I'm not in a position to demand anything.
It isn't about demanding it is about being respected as a professional.

If you make a logical case and are rebuffed find a better job.
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damorgan@x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org


Reply With Quote
  #24  
Old   
mowinom@hotmail.com
 
Posts: n/a

Default Re: Conditional Trigger - 11-22-2007 , 05:29 AM



Thanks Daniel.

I'll chew on them (the acm articles) one by one buy of now, let me
solve this current puzzle first.

Regards,
Mark


On Nov 21, 3:14 pm, DA Morgan <damor... (AT) psoug (DOT) org> wrote:
Quote:
mowi... (AT) hotmail (DOT) com wrote:
This, still, is using a relational database as a relational database.
The only new thing here is that the relation has been specialized at
the column level; an aspect not currently explicitly supported by
Oracle.

Perhaps you missed this:http://portal.acm.org/citation.cfm?doid=362384.362685
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damor...@x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Groupwww.psoug.org


Reply With Quote
  #25  
Old   
Galen Boyer
 
Posts: n/a

Default Re: Conditional Trigger - 11-24-2007 , 03:09 PM



On Tue, 20 Nov 2007, mowinom (AT) hotmail (DOT) com wrote:

Quote:
Problem is that a pannel decided that it be done as specified
above. There are already too many tables in the database already.
It sounds to me that the designs of the "too-many tabled" database
probably has quite a few really really poorly designed tables which
cause headache after headache. So, new poorly designed tables (of which
this one is) start compounding the problems. But, the real problem is
that the designer/s of the tables in this database never knew what they
were doing in the first place.

I guess if I was paying for it and I knew nothing about databases and
all I knew was that a new table equated to more problems, I'd be
inclined to keep the number of tables at a bare minimum as well.

--
Galen Boyer


Reply With Quote
  #26  
Old   
Frank van Bortel
 
Posts: n/a

Default Re: Conditional Trigger - 11-25-2007 , 04:56 AM



You have my sympathy.

--
Regards,
Frank van Bortel

Top-posting is one way to shut me up...

Reply With Quote
  #27  
Old   
mowinom@hotmail.com
 
Posts: n/a

Default Re: Conditional Trigger - 11-28-2007 , 06:09 AM



Hi All,

I solved the puzzle buy using two cursors. One cursor fetched all
records that equaled :New.ISBN and the other fetched records in the
periodical# column that equaled :New.periodical#_Owner.

After that, I used a conditional check to ensure that if the ISBN
being entered in the table already existed then periodical#_Owner was
to be provided and that it had to be equal an existing periodical#.

The trigger is working fine and I'm happy with it. Thanks to you all
for your suggestions and helpful criticism; special thanks to David
and Daniel.

Regards,
Mark

Reply With Quote
  #28  
Old   
fitzjarrell@cox.net
 
Posts: n/a

Default Re: Conditional Trigger - 11-28-2007 , 07:41 AM



On Nov 28, 6:09 am, mowi... (AT) hotmail (DOT) com wrote:
Quote:
Hi All,

I solved the puzzle buy using two cursors. One cursor fetched all
records that equaled :New.ISBN and the other fetched records in the
periodical# column that equaled :New.periodical#_Owner.

After that, I used a conditional check to ensure that if the ISBN
being entered in the table already existed then periodical#_Owner was
to be provided and that it had to be equal an existing periodical#.

The trigger is working fine and I'm happy with it. Thanks to you all
for your suggestions and helpful criticism; special thanks to David
and Daniel.

Regards,
Mark
You're welcome.


David Fitzjarrell


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 - 2012, Jelsoft Enterprises Ltd.