I wrote a SQL script as below, while executing it, encountered 'PLS-00103: Encountered the symbol "CREATE"' error.
logging.sql
----
DROP SEQUENCE pt_debug_sequence;
CREATE SEQUENCE pt_debug_sequence
START WITH 1
INCREMENT BY 1
NOMAXVALUE
NOCYCLE
CACHE 10;
DROP TABLE pt_debug_tab;
CREATE TABLE pt_debug_tab (seq INTEGER, text VARCHAR2(300), datetag VARCHAR2(30));
CREATE OR REPLACE
PROCEDURE pt_debug(inStr VARCHAR2) IS
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
INSERT INTO pt_debug_tab VALUES(pt_debug_sequence.NEXTVAL, inStr, to_char(sysdate, 'MM/DD/YYYY HH24:MI:SS'));
COMMIT;
END;
/ -- There should be ended with '/'
CREATE OR REPLACE
PROCEDURE putline IS
--v_line varchar2(40);
--intime varchar2(40);
--outtime varchar2(40);
BEGIN
--select to_char(sysdate, 'MM/DD/YYYY HH:MI:SS') into intime from dual;
--dbms_output.put_line('Start Time:'||intime);
--dbms_output.put_line('Start Time:'||to_char(sysdate, ));
--v_line := 'hello world';
--dbms_output.put_line(v_line);
--dbms_lock.sleep(30);
--select to_char(sysdate, 'MM/DD/YYYY HH:MI:SS') into outtime from dual;
pt_debug('dbms_lock.sleep(30)');
--dbms_output.put_line('End Time:'||outtime);
END;
/
========
SQL> @logging.sql
Sequence dropped.
Sequence created
Table dropped.
Table created.
Warning: Procedure created with compilation errors.
SQL> show errors
Errors for PROCEDURE PT_DEBUG:
LINE/COL ERROR
-------- -----------------------------------------------------------------
9/1 PLS-00103: Encountered the symbol "CREATE"
SQL>
=============
The problem is forgetting to add '/' for the first procedure. When we encounter this kind of issue, usually, we miss adding something or the variable is reserved one etc.
在执行SQL脚本时遇到了'PLS-00103: Encountered the symbol "CREATE"'的错误。问题出在第一个过程声明末尾缺少'/'。修复此问题后,脚本成功创建了序列和表,但第二个过程PT_DEBUG创建时出现编译错误。
2万+

被折叠的 条评论
为什么被折叠?



