Home » SQL & PL/SQL » SQL & PL/SQL » Updating table using triggers
Updating table using triggers [message #330302] Sun, 29 June 2008 03:25 Go to next message
jyothsna1612
Messages: 68
Registered: June 2008
Member
Hi,
Can u check the following ex:
create or replace trigger tr1
after update on t4
for each row
begin
update t5 set c=:new.b;
end tr1;
/

Trigger created.


but why the following trigger is showing errors

create or replace trigger tr1
after update on t4
for each row
begin
update t5 set c=:new.b and d=:new.a;
end tr1;
/


Warning: Trigger created with compilation errors.

2/1 PL/SQL: SQL Statement ignored
2/24 PL/SQL: ORA-00933: SQL command not properly ended

Re: Updating table using triggers [message #330303 is a reply to message #330302] Sun, 29 June 2008 03:51 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Did you check the syntax for the UPDATE statement in the documentation?
Where did you see that you can use AND in such a way?

Note: In addition to your syntax-error, you probably also got a logical error, since you lack a where clause on your update. This would result in the complete t5 table being updated.
Re: Updating table using triggers [message #330306 is a reply to message #330302] Sun, 29 June 2008 04:38 Go to previous messageGo to next message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Also please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.
Always post your Oracle version (4 decimals).

Regards
Michel
Re: Updating table using triggers [message #330310 is a reply to message #330306] Sun, 29 June 2008 05:44 Go to previous message
jyothsna1612
Messages: 68
Registered: June 2008
Member
Sorry. I got why the error now.
I would have checked the syntax properly before posting
Previous Topic: UPDATE statement caused error
Next Topic: Getting ORA-1427: single-row subquery returns more than one row
Goto Forum:
  


Current Time: Sun Dec 11 02:40:24 CST 2016

Total time taken to generate the page: 0.05775 seconds