Donnerstag, 13. Juni 2024

ORA-01756 in SQL+ a statement is not terminated correctly using q' bla '

Explanation

I consider this in this case as a bug. The message is misleading as the it is parser internally (SQL+) not properly set quotes. Indirectly, it is a correct message because of the shortcomings of the parser, the end of the statement gets identified incorrectly.

The problem probably arises because the parser cannot handle quoted strings that contain either

  1. lines containing the semi-colon as last character like

    --SQL
    insert into STATEMENTS_COLLECTION (STATEMENTS) values (q'select * from DUAL;
    delete from DUAL where 1 = 0;'
  2. empty lines, including lines only containing white space characters, though the latter has been tested only with space characters



Solution

    style="text-align: left;">
  1. Switch off the terminator
    -- SQL
    -- prevent ORA-01756
    set sqlterminator off
    
    /* do your magic statement here */
    /
    
    set sqlterminator on
    
  2. Allow blank lines
    -- SQL
    -- prevent ORA-01756
    set sqlblanklines on
    
    /* do your magic statement here */
    /
    
    set sqlblanklines off


ORA-01722 Invalid number when having implicit conversions (in Toad)

-- SQL
select to_number('0.46') from dual;

The solution is the same as with the UTF-8 problem UTF-8 problem.