Home » SQL & PL/SQL » SQL & PL/SQL » Trigger
Trigger [message #185779] Thu, 03 August 2006 09:59 Go to next message
Messages: 2
Registered: August 2006
Junior Member
I am a newbie in oracle as well as in sql.
I am getting compilation errors with the following trigger.
create or replace trigger weekly_member_ins_row
before insert on weekly_member
for each row
update groups
set no_of_member=no_of_member+1
from groups,nrow
where groups.member_group_name=new.member_group_name;

line/col error
2/1 sql statement ignored
3/33 ora-00933:sql command not properly ended

Please any one help me.

Re: Trigger [message #185781 is a reply to message #185779] Thu, 03 August 2006 10:03 Go to previous messageGo to next message
Messages: 189
Registered: May 2006
Location: NJ,USA
Senior Member

error in your update query.
Check for update syntax and try to modify the update query..

From the query I assume that u want to perform below condition...
column no_of_member of table groups should be increment by 1 if the inserted member_group_name exists in both the tables nrow and groups.

if yes, refer to below query..

update groups
set no_of_member=no_of_member+1
where exists (select 'X' from nrow
              where nrow.member_group_name=:new.member_group_name
	    and groups.member_group_name=nrow.member_group_name);


[Updated on: Thu, 03 August 2006 10:12]

Report message to a moderator

Re: Trigger [message #186017 is a reply to message #185779] Fri, 04 August 2006 14:26 Go to previous message
Bill B
Messages: 1474
Registered: December 2004
Senior Member
Maintaining a count of the members is typically not a very good idea. What about updates and deletes. It is MUCH more efficient to perform a query against your members table at the time you need the count. It is guaranteed to always be correct.
Previous Topic: select statement in NVL or decode?
Next Topic: Query help please
Goto Forum:

Current Time: Wed Oct 26 04:53:30 CDT 2016

Total time taken to generate the page: 0.11975 seconds