Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 21st, 2005, 06:57 AM
Germanjulian Germanjulian is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: London UK
Posts: 131 Germanjulian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 32 m 40 sec
Reputation Power: 6
Trigger Help! Compliation error

I have two tables, a client table with clientID, and a contact table with clientID as a foreign key. I wish to write a trigger that will not allow a user to input a new contact for a client where there are already 2 rows with the same client id. I have the following code:

Code:
create trigger contact_trigger Before insert on contact --for each row
begin
	if (select count(contact.clientID) as contCount from contact where contact.clientid:=new.clientid)>=2 THEN
		raise_application_error(-20000, 'You''ve entered too many contacts')
	end if;
end contact_trigger;

(note: I have commented out the for each row statement)

When I execute this code i get the following error

Code:
Warning: Trigger created with compilation errors.


Please can somebody direct me to:

a) a method of debugging
b) the actual error

Thanks in advance
__________________
GermanJulian.com

Reply With Quote
  #2  
Old March 21st, 2005, 07:08 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,917 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 15 h 52 m 3 sec
Reputation Power: 279
Read an introductive tutorial

Reply With Quote
  #3  
Old March 21st, 2005, 08:32 PM
merl merl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 51 merl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 34 sec
Reputation Power: 7
run the command "show errors;" after your trigger.

Reply With Quote
  #4  
Old March 22nd, 2005, 03:36 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,917 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 15 h 52 m 3 sec
Reputation Power: 279
If you want your clientid to be unique simply add a unique constraint or set it as the primary key.
Note that your trigger does not check unicity in case of an update, is this what you want?
And you didn't fetch the selected value into a variable.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Trigger Help! Compliation error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT