Home » SQL & PL/SQL » SQL & PL/SQL » PLS-00103: Encountered the symbol "CREATE"
PLS-00103: Encountered the symbol "CREATE" [message #115856] Thu, 14 April 2005 13:48 Go to next message
m_scandroglio
Messages: 26
Registered: March 2005
Junior Member
Hi all!
I have a problem:

alter trigger CAN_CHIAVE compile;

Warning: Trigger altered with compilation errors.

SQL> show error
Errors for TRIGGER CAN_CHIAVE:

LINE/COL ERROR
-------- -----------------------------------------------------------------
14/1 PLS-00103: Encountered the symbol "CREATE"

The trigger syntax is correct 'cause the same script to create it has been launched on other 3 schema identical!!!

any idea????

thanks!
Re: PLS-00103: Encountered the symbol "CREATE" [message #115874 is a reply to message #115856] Thu, 14 April 2005 14:55 Go to previous messageGo to next message
smartin
Messages: 1803
Registered: March 2005
Location: Jacksonville, Florida
Senior Member
Care to post the syntax?
Re: PLS-00103: Encountered the symbol "CREATE" [message #115916 is a reply to message #115874] Fri, 15 April 2005 04:32 Go to previous messageGo to next message
m_scandroglio
Messages: 26
Registered: March 2005
Junior Member
CREATE OR REPLACE TRIGGER CAN_CHIAVE
AFTER UPDATE OF D_FINE_VALIDITA ON CHIAVI FOR EACH ROW

BEGIN

IF DBMS_REPUTIL.FROM_REMOTE = FALSE THEN

UPDATE SET_CHIAVI
SET Q_CHIAVI_DISPONIBILI = Q_CHIAVI_DISPONIBILI - 1
WHERE K_ID_SET = :new.E_ID_SET
AND Q_CHIAVI_DISPONIBILI > 0;

END IF;

END;

any suggestions? I can't understand why on the others db there's not problem!!
Re: PLS-00103: Encountered the symbol "CREATE" [message #116002 is a reply to message #115916] Fri, 15 April 2005 18:14 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9090
Registered: November 2002
Location: California, USA
Senior Member
Something must be different. I find it curious that your error message says that it is finding "CREATE" on line 14, but there is no "CREATE" on line 14 of the code that you posted. What does the following produce?

break on owner
column text format a45 word_wrapped
select owner, text
from all_source
where name = 'CAN_CHIAVE'
order by owner, line
/
Re: PLS-00103: Encountered the symbol "CREATE" [message #116044 is a reply to message #116002] Sat, 16 April 2005 18:14 Go to previous messageGo to next message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
Quote:

but there is no "CREATE" on line 14 of the code that you posted

Or a line 14. There are only 12 lines of PL/SQL.
Re: PLS-00103: Encountered the symbol "CREATE" [message #116047 is a reply to message #116044] Sat, 16 April 2005 20:17 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9090
Registered: November 2002
Location: California, USA
Senior Member
I believe Oracle counts the blank lines when numbering them, so there are 15 lines, if you include the blank ones.

Re: PLS-00103: Encountered the symbol "CREATE" [message #116097 is a reply to message #115856] Sun, 17 April 2005 12:57 Go to previous messageGo to next message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
Yes, Oracle counts blank lines. But there are still only 12 lines of PL/SQL Wink

SQL> ho cat data/sql/test_trigger_lines.trg
CREATE OR REPLACE TRIGGER CAN_CHIAVE
AFTER UPDATE OF D_FINE_VALIDITA ON CHIAVI FOR EACH ROW

BEGIN
THIS_IS_LINE_2;  -- Check the error listing when this code fails

IF DBMS_REPUTIL.FROM_REMOTE = FALSE THEN

UPDATE SET_CHIAVI
SET Q_CHIAVI_DISPONIBILI = Q_CHIAVI_DISPONIBILI - 1
WHERE K_ID_SET = :new.E_ID_SET
AND Q_CHIAVI_DISPONIBILI > 0;

END IF;

END;
/

SQL> @data/sql/test_trigger_lines.trg

Warning: Trigger created with compilation errors.

SQL> show errors
Errors for TRIGGER CAN_CHIAVE:

LINE/COL ERROR
-------- -----------------------------------------------------------------
2/1      PLS-00201: identifier 'THIS_IS_LINE_2' must be declared
2/1      PL/SQL: Statement ignored
SQL> 
Re: PLS-00103: Encountered the symbol "CREATE" [message #116105 is a reply to message #116097] Sun, 17 April 2005 15:50 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9090
Registered: November 2002
Location: California, USA
Senior Member
Interesting. It appears that, when displaying the line number of an error message, it does count the blank lines, but begins counting from the line with the keyword "begin", which does not correspond to the line numbers it uses anywhere else. All this time I never noticed that.

scott@ORA92> create table chiavi
  2    (d_fine_validita number,
  3  	e_id_set	number)
  4  /

Table created.

scott@ORA92> create table set_chiavi
  2    (Q_CHIAVI_DISPONIBILI number,
  3  	k_id_set	     number)
  4  /

Table created.

scott@ORA92> CREATE OR REPLACE TRIGGER CAN_CHIAVE
  2    AFTER UPDATE OF D_FINE_VALIDITA ON CHIAVI
  3    FOR EACH ROW
  4  
  5  BEGIN
  6  
  7    IF DBMS_REPUTIL.FROM_REMOTE = FALSE THEN
  8  
  9  	 UPDATE SET_CHIAVI
 10  	 SET	Q_CHIAVI_DISPONIBILI = Q_CHIAVI_DISPONIBILI - 1
 11  	 WHERE	K_ID_SET = :new.E_ID_SET
 12  	 AND	Q_CHIAVI_DISPONIBILI > 0;
 13  
 14    END IF;
 15  
 16  END;
 17  /

Trigger created.

scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> alter trigger CAN_CHIAVE compile
  2  /

Trigger altered.

scott@ORA92> show errors
No errors.
scott@ORA92> column text format a45 word_wrapped
scott@ORA92> select line, text
  2  from   user_source
  3  where  name = 'CAN_CHIAVE'
  4  order  by line
  5  /

      LINE TEXT
---------- ---------------------------------------------
         1 TRIGGER CAN_CHIAVE
         2 AFTER UPDATE OF D_FINE_VALIDITA ON CHIAVI
         3 FOR EACH ROW
         4
         5 BEGIN
         6
         7 IF DBMS_REPUTIL.FROM_REMOTE = FALSE THEN
         8
         9 UPDATE SET_CHIAVI
        10 SET    Q_CHIAVI_DISPONIBILI =
           Q_CHIAVI_DISPONIBILI - 1

        11 WHERE  K_ID_SET = :new.E_ID_SET
        12 AND    Q_CHIAVI_DISPONIBILI > 0;
        13
        14 END IF;
        15
        16 END;

16 rows selected.

scott@ORA92> CREATE OR REPLACE TRIGGER CAN_CHIAVE
  2    AFTER UPDATE OF D_FINE_VALIDITA ON CHIAVI
  3    FOR EACH ROW
  4  
  5  BEGIN
  6  
  7    IF DBMS_REPUTIL.FROM_REMOTE = FALSE THEN
  8  
  9  	 UPDATE SET_CHIAVI
 10  	 SET	Q_CHIAVI_DISPONIBILI = Q_CHIAVI_DISPONIBILI - 1
 11  	 WHERE	K_ID_SET = :new.E_ID_SET
 12  	 AND	Q_CHIAVI_DISPONIBILI > 0;
 13  
 14    line14; END IF;
 15  
 16  END;
 17  /

Warning: Trigger created with compilation errors.

scott@ORA92> SHOW ERRORS
Errors for TRIGGER CAN_CHIAVE:

LINE/COL ERROR
-------- -----------------------------------------------------------------
10/3     PLS-00201: identifier 'LINE14' must be declared
10/3     PL/SQL: Statement ignored
scott@ORA92> CREATE OR REPLACE TRIGGER CAN_CHIAVE
  2    AFTER UPDATE OF D_FINE_VALIDITA ON CHIAVI
  3    FOR EACH ROW
  4  BEGIN
  5    IF DBMS_REPUTIL.FROM_REMOTE = FALSE THEN
  6  	 UPDATE SET_CHIAVI
  7  	 SET	Q_CHIAVI_DISPONIBILI = Q_CHIAVI_DISPONIBILI - 1
  8  	 WHERE	K_ID_SET = :new.E_ID_SET
  9  	 AND	Q_CHIAVI_DISPONIBILI > 0;
 10    line10; END IF;
 11  END;
 12  /

Warning: Trigger created with compilation errors.

scott@ORA92> SHOW ERRORS
Errors for TRIGGER CAN_CHIAVE:

LINE/COL ERROR
-------- -----------------------------------------------------------------
7/3      PLS-00201: identifier 'LINE10' must be declared
7/3      PL/SQL: Statement ignored

Re: PLS-00103: Encountered the symbol "CREATE" [message #116162 is a reply to message #115856] Mon, 18 April 2005 06:45 Go to previous messageGo to next message
himang
Messages: 282
Registered: March 2005
Location: Bangalore
Senior Member

Is the error to do something with "DBMS_REPUTIL.FROM_REMOTE" procedure called in the trigger??

Can someone throw some light on what this package is used for??

Regards
Himanshu
Re: PLS-00103: Encountered the symbol "CREATE" [message #116232 is a reply to message #116162] Mon, 18 April 2005 13:54 Go to previous messageGo to next message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
I suspect we are dealing with a SQL*Plus script that has lost a "/" character or similar, so that two statements are being joined together and the "CREATE" is supposed to be the start of the next one.

Having read the documentation on DBMS_REPUTIL.FROM_REMOTE I must admit I'm not much the wiser about what it's for or what, if anything, it's doing in this trigger.

[Updated on: Mon, 18 April 2005 14:00]

Report message to a moderator

Re: PLS-00103: Encountered the symbol "CREATE" [message #116267 is a reply to message #115856] Mon, 18 April 2005 23:57 Go to previous messageGo to next message
himang
Messages: 282
Registered: March 2005
Location: Bangalore
Senior Member

But the command used is "alter trigger CAN_CHIAVE compile;" so there is no sql*PLUS script as it will just pick the source stored in database and re-compile it.

Seems to be a strange problem...

m_scandroglio - Are you able to create any other object in that particular database. Can you try to give the same command for some other trigger, just to check whether its a problem with this trigger source or some other DB problem...

Give it a try!!

Regards
Himanshu
Re: PLS-00103: Encountered the symbol "CREATE" [message #116273 is a reply to message #115856] Tue, 19 April 2005 01:06 Go to previous messageGo to next message
Frank
Messages: 7901
Registered: March 2000
Senior Member
My first idea was similar to William's: an incomplete SQL-script.
Is the alter trigger command issued from a script or do you type it from the (sqlplus) command line ?

hth
Re: PLS-00103: Encountered the symbol "CREATE" [message #116278 is a reply to message #116273] Tue, 19 April 2005 03:09 Go to previous messageGo to next message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
Quote:

But the command used is "alter trigger CAN_CHIAVE compile;" so there is no sql*PLUS script as it will just pick the source stored in database and re-compile it.

Well obviously the source code got into the database somehow, possibly from a script that contained an error?

test_trigger.trg:
CREATE OR REPLACE TRIGGER CAN_CHIAVE
AFTER UPDATE OF D_FINE_VALIDITA ON CHIAVI FOR EACH ROW
BEGIN
    IF DBMS_REPUTIL.FROM_REMOTE = FALSE THEN

        UPDATE SET_CHIAVI
        SET Q_CHIAVI_DISPONIBILI = Q_CHIAVI_DISPONIBILI - 1
        WHERE K_ID_SET = :new.E_ID_SET
        AND Q_CHIAVI_DISPONIBILI > 0;

    END IF;

END;

CREATE OR REPLACE TRIGGER some_other_trigger
AFTER UPDATE OF D_FINE_VALIDITA ON CHIAVI FOR EACH ROW
etc blah blah
/


SQL> @test_trigger.trg

Warning: Trigger created with compilation errors.

SQL> show errors
Errors for TRIGGER CAN_CHIAVE:

LINE/COL ERROR
-------- -----------------------------------------------------------------
13/1     PLS-00103: Encountered the symbol "CREATE"
SQL> 
SQL> ALTER TRIGGER CAN_CHIAVE COMPILE;

Warning: Trigger altered with compilation errors.

SQL> show errors
Errors for TRIGGER CAN_CHIAVE:

LINE/COL ERROR
-------- -----------------------------------------------------------------
13/1     PLS-00103: Encountered the symbol "CREATE"
SQL>

Re: PLS-00103: Encountered the symbol "CREATE" [message #116312 is a reply to message #116278] Tue, 19 April 2005 06:53 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Put a "/" after the first creation statement:
CREATE OR REPLACE TRIGGER CAN_CHIAVE
AFTER UPDATE OF D_FINE_VALIDITA ON CHIAVI FOR EACH ROW
BEGIN
IF DBMS_REPUTIL.FROM_REMOTE = FALSE THEN

UPDATE SET_CHIAVI
SET Q_CHIAVI_DISPONIBILI = Q_CHIAVI_DISPONIBILI - 1
WHERE K_ID_SET = :new.E_ID_SET
AND Q_CHIAVI_DISPONIBILI > 0;

END IF;

END;
/
CREATE OR REPLACE TRIGGER some_other_trigger

MHE
Re: PLS-00103: Encountered the symbol "CREATE" [message #116365 is a reply to message #116312] Tue, 19 April 2005 12:12 Go to previous messageGo to next message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
That was kind of my point... Wink
Re: PLS-00103: Encountered the symbol "CREATE" [message #116431 is a reply to message #116365] Wed, 20 April 2005 02:02 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
I know, William, all credit go to you Thumbs Up

I was merely confirming your assumption...

MHE
Re: PLS-00103: Encountered the symbol "CREATE" [message #118302 is a reply to message #116267] Wed, 04 May 2005 04:12 Go to previous messageGo to next message
m_scandroglio
Messages: 26
Registered: March 2005
Junior Member
Hi all!
BUT THE SAME SCRIPT LAUNCHED in another db works!! and the trigger is valid!!
I can understand...Sad(
Re: PLS-00103: Encountered the symbol "CREATE" [message #118307 is a reply to message #118302] Wed, 04 May 2005 04:37 Go to previous messageGo to next message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
Might be a good time to post the code.
Re: PLS-00103: Encountered the symbol "CREATE" [message #118309 is a reply to message #115856] Wed, 04 May 2005 04:49 Go to previous messageGo to next message
m_scandroglio
Messages: 26
Registered: March 2005
Junior Member
That's it!

CREATE OR REPLACE TRIGGER CAN_CHIAVE
AFTER UPDATE OF D_FINE_VALIDITA ON CHIAVI FOR EACH ROW

DECLARE
d_fine_val_cl CLIENTI.D_FINE_VALIDITA%TYPE;
d_fine_val_set SET_CHIAVI.D_FINE_VALIDITA%TYPE;
tipo_evento EVENTI.K_ID_EVENTO%TYPE;
stato_set STATI_SET.N_DESCR_BREVE%TYPE;
chiavi_disp Number(3);
soglia Number(3);
cod_banca BANCHE.N_COD_BANCA%TYPE;
user_id CLIENTI.N_USER_ID%TYPE;
id_gen GEN_AUTO.K_ID_GEN_AUTO%TYPE;
new_record Boolean := false;

BEGIN

IF DBMS_REPUTIL.FROM_REMOTE = FALSE THEN

UPDATE SET_CHIAVI
SET Q_CHIAVI_DISPONIBILI = Q_CHIAVI_DISPONIBILI - 1
WHERE K_ID_SET = :new.E_ID_SET
AND Q_CHIAVI_DISPONIBILI > 0;

END IF;

SELECT D_FINE_VALIDITA INTO d_fine_val_cl FROM CLIENTI
WHERE K_ID_CLIENTE = :new.E_ID_CLIENTE;

SELECT D_FINE_VALIDITA INTO d_fine_val_set FROM SET_CHIAVI
WHERE K_ID_SET = :new.E_ID_SET;

SELECT N_DESCR_BREVE INTO stato_set FROM STATI_SET SS
INNER JOIN STATI_SET_BANCA SSB ON SS.K_ID_STATO_SET = SSB.E_ID_STATO_SET
INNER JOIN SET_CHIAVI S ON S.E_ID_STATO_SET_BANCA = SSB.K_ID_STATO_SET_BANCA
WHERE K_ID_SET = :new.E_ID_SET
AND SS.D_FINE_VALIDITA IS NULL;

IF ((d_fine_val_cl IS NULL) AND (stato_set <> 'UTL') AND (d_fine_val_set IS NULL)) THEN

SELECT K_ID_EVENTO INTO tipo_evento FROM EVENTI
WHERE N_DESCR_BREVE = 'BRU' -- ID evento di Bruciatura chiave del set
AND D_FINE_VALIDITA IS NULL;


INSERT INTO STORICO VALUES
(S_STORICO.NEXTVAL,
:new.E_ID_CLIENTE,
(SELECT E_ID_CODICE_CANALI FROM SET_CHIAVI WHERE K_ID_SET = :new.E_ID_SET),
(SELECT E_ID_BANCA FROM SET_CHIAVI WHERE K_ID_SET = :new.E_ID_SET),
tipo_evento,
:new.D_FINE_VALIDITA,
SYSDATE,
(SELECT N_USER_AGGIORNA FROM SET_CHIAVI WHERE K_ID_SET = :new.E_ID_SET));


SELECT Q_CHIAVI_DISPONIBILI, Q_SOGLIA_CHIAVI INTO chiavi_disp, soglia FROM SET_CHIAVI
WHERE K_ID_SET = :new.E_ID_SET;


IF (chiavi_disp - 1 = soglia) THEN

SELECT N_COD_BANCA INTO cod_banca FROM BANCHE
WHERE K_ID_BANCA = (SELECT E_ID_BANCA FROM SET_CHIAVI WHERE K_ID_SET = :new.E_ID_SET)
AND D_FINE_VALIDITA IS NULL;

SELECT N_USER_ID INTO user_id FROM CLIENTI WHERE K_ID_CLIENTE = :new.E_ID_CLIENTE;

BEGIN
SELECT K_ID_GEN_AUTO INTO id_gen FROM GEN_AUTO
WHERE N_USER_ID = user_id
AND N_COD_BANCA = cod_banca;

EXCEPTION WHEN OTHERS THEN

new_record := true;
END;

IF (new_record = true) THEN

INSERT INTO GEN_AUTO (K_ID_GEN_AUTO,N_USER_ID,N_COD_BANCA,F_PROCESSATO,D_AGGIORN_REC)
VALUES (S_GEN_AUTO.NEXTVAL, user_id, cod_banca, 'N', SYSDATE);
END IF;

IF (new_record = false) THEN

UPDATE GEN_AUTO SET F_PROCESSATO = 'N', D_AGGIORN_REC = SYSDATE
WHERE N_USER_ID = user_id AND N_COD_BANCA = cod_banca;

END IF;

END IF;

END IF;
END;
Re: PLS-00103: Encountered the symbol "CREATE" [message #118381 is a reply to message #118309] Wed, 04 May 2005 15:52 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9090
Registered: November 2002
Location: California, USA
Senior Member
It is obvious to everyone but you, that when the script that you have provided was originally run, the final / was omitted and the next create statement was appended to it. So, when you try to alter compile, it tries to re-run that. Hopefully, this should show up when you run the code that I have provided below. Please run the code below and copy and paste the complete results.

select owner, trigger_name, trigger_body
from all_triggers
where name = 'CAN_CHIAVE'
order by owner
/

If you just want to fix the problem, then try dropping the trigger and re-running your script, making sure that you include a / at the end. Then your alter compile should work after that.


Re: PLS-00103: Encountered the symbol "CREATE" [message #124328 is a reply to message #118381] Fri, 17 June 2005 09:48 Go to previous messageGo to next message
mannyrdi
Messages: 1
Registered: June 2005
Junior Member
Hey you all, I'm getting the same kind of error. Here's my procedure:


CREATE OR REPLACE PROCEDURE recreate_seqs
IS
rows NUMBER;
start_num NUMBER;
BEGIN
start_num := 1661168;

SELECT COUNT(rowid) INTO rows FROM ADDL_CHG_GROUPS;
rows := rows + start_num + 1;
CREATE SEQUENCE ADDL_CHG_GROUP_SQ START WITH rows;
END;
/

show errors
Errors for PROCEDURE RECREATE_SEQS

9/1 PLS-00103: Encountered the symbol "CREATE" when expecting one of the following: begin declare end exception for goto....

I'm sure it's something simple that I'm missing!!

-Manny
Re: PLS-00103: Encountered the symbol "CREATE" [message #124333 is a reply to message #115856] Fri, 17 June 2005 10:21 Go to previous message
JSI2001
Messages: 1016
Registered: March 2005
Location: Scotland
Senior Member
Hi

CREATE OR REPLACE PROCEDURE recreate_seqs
IS
rows NUMBER;
start_num NUMBER;
BEGIN
start_num := 1661168;

SELECT COUNT(rowid) INTO rows FROM ADDL_CHG_GROUPS;
rows := rows + start_num + 1;
execute immediate 'CREATE SEQUENCE ADDL_CHG_GROUP_SQ START WITH '||rows||';';
END;
/

show errors
Previous Topic: Dense Rank not getting the desired output
Next Topic: Query to show Columns in Row wise
Goto Forum:
  


Current Time: Fri Apr 26 14:53:13 CDT 2024