Search code examples
oracle-databaseoracle10gsqlplus

Semicolon and Single Quote Issue in SQL Insert Statements


I am executing a SQL script which has spaces, semicolons, single-quotes, special characters etc. in of the column called prod_desc. I need to execute the script from SQLPLUS. I have the set the following in the SQLPLUS however, single quotes, semicolons are not taken into consideration.

set sqlblanklines on

See the below insert statement for instance, semicolon is after the line break. This is causing an error during execution. How can I resolve the issue?

SET DEFINE OFF;
Insert into PROD_DESC
   (PROD_NO, PROD_DESC
    )
Values
   ('XYZ', 'test
semicolon test;
'
);

Table Structure

CREATE TABLE prod_desc
(
   prod_no     VARCHAR2 (100),
   prod_desc   VARCHAR2 (1000)
);

Solution

  • Espace the semicolon:

    SET DEF OFF;
    Insert into PROD_DESC(PROD_NO, PROD_DESC)
    Values('XYZ', 'test semicolon test\;');