Home » SQL & PL/SQL » SQL & PL/SQL » triggers (Oracle, 10g, windows XP)
triggers [message #330716] Tue, 01 July 2008 00:45 Go to next message
jyothsna1612
Messages: 68
Registered: June 2008
Member
I'm unable to find why the error
CREATE TABLE test
(id NUMBER PRIMARY KEY,
name VARCHAR2(30))

table created
CREATE SEQUENCE test_sequence
START WITH 1
INCREMENT BY 1

sequence created

CREATE OR REPLACE TRIGGER test_trigger
BEFORE INSERT
ON test
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT test_sequence.nextval INTO :NEW.ID FROM dual;
END;

Error is:
2/52 PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
;

I even tried disable the trigger and tried it again
but still the error is coming
Re: triggers [message #330723 is a reply to message #330716] Tue, 01 July 2008 01:01 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Make sure you add a slash to actually execute the code (per command):
SQL> conn scott/tiger
Connected.
SQL> CREATE TABLE test
  2  (id NUMBER PRIMARY KEY,
  3  name VARCHAR2(30))
  4  /

Table created.

SQL> CREATE SEQUENCE test_sequence
  2  START WITH 1
  3  INCREMENT BY 1
  4  /

Sequence created.

SQL> CREATE OR REPLACE TRIGGER test_trigger
  2  BEFORE INSERT
  3  ON test
  4  REFERENCING NEW AS NEW
  5  FOR EACH ROW
  6  BEGIN
  7  SELECT test_sequence.nextval INTO :NEW.ID FROM dual;
  8  END;
  9  /

Trigger created.

No problem in your code.
Re: triggers [message #330725 is a reply to message #330716] Tue, 01 July 2008 01:02 Go to previous messageGo to next message
Michel Cadot
Messages: 64117
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You MUST copy and paste your session.
Currently none of your statements are terminated, so this error is expected.

Regards
Michel
Re: triggers [message #330731 is a reply to message #330725] Tue, 01 July 2008 01:09 Go to previous messageGo to next message
jyothsna1612
Messages: 68
Registered: June 2008
Member
I'm trying this code in TOAD 9 version.
and in
MACHJYO @10.91.123.8:1521/testdb-Editor
window .
In this the same error is coming for the following code also
DECLARE
v1  NUMBER(3);
BEGIN
   v1 := 3;
   DBMS_OUTPUT.PUT_LINE('v1=' || v1); 
END;


I think the problem might be in the window.
As I'm new to the TOAD, please excuse me if i ask simple doubts
Re: triggers [message #330743 is a reply to message #330731] Tue, 01 July 2008 01:44 Go to previous messageGo to next message
Michel Cadot
Messages: 64117
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
If you want to learn don't use TOAD, use SQL*Plus.

Regards
Michel
Re: triggers [message #330745 is a reply to message #330716] Tue, 01 July 2008 01:52 Go to previous message
jyothsna1612
Messages: 68
Registered: June 2008
Member
Yes, I got the output
I came to know that whenever we try to execute procedure/fun/trig
in toad we need to press F5(execute script)
Earlier I executed it as sql stmt.so It's giving error..

Anyway I'll follow the Cadot advice for practicing.
Thank you very much
Previous Topic: How to find out if a session is hung?
Next Topic: Insert/Delete Trigger
Goto Forum:
  


Current Time: Tue Dec 06 04:31:03 CST 2016

Total time taken to generate the page: 0.09594 seconds