Home
Syntax Errors
Description
A syntax error in PL/SQL code occurs when the code does not follow the rules of the PL/SQL language. This type of error can be caused by incorrect spelling, incorrect punctuation, incorrect capitalization, or incorrect use of reserved words. Syntax errors can prevent the code from being executed, and can cause the code to produce unexpected results. In order to avoid syntax errors, it is important to read and understand the PL/SQL language and to follow the rules of the language when writing code.
Key Benefits
- Accuracy: Syntax Errors rule ensure accuracy by providing a clear set of rules for writing code.
- Consistency: Syntax Errors rule provide consistency by ensuring that code is written in the same way across different programming languages.
- Efficiency: Syntax Errors rule help to make code more efficient by reducing the amount of time spent debugging and troubleshooting.
- Readability: Syntax Errors rule make code easier to read and understand by providing a consistent structure.
Non-compliant Code Example
CREATE OR REPLACE PROCEDURE DeleteCustomer() --Non compliant code (Extra "(" and ")" because no parameter pass)
IS
cursor_name INTEGER;
BEGIN
cursor_name := dbms_sql.open_cursor;
DBMS_SQL.PARSE(cursor_name, 'DELETE FROM CUSTOMER WHERE isNotActive',DBMS_SQL.NATIVE);
DBMS_SQL.CLOSE_CURSOR(cursor_name);
END;
create TABLE SITE
(
ID number(10) NOT NULL --Non compliant code (Missing COMMA)
NAME NVARCHAR2(50),
Manager_Id int,
CONSTRAINT SITE_pk PRIMARY KEY (ID)
);