Skip to content

[plsql] In StringLiteral using alternative quoting mechanism single quotes cause parsing errors #2008

@adangel

Description

@adangel

Affects PMD Version: 6.17.0

Rule: n/a

Description:
When using (multiline) StringLiterals with a custom start and end delimiter (alternative quoting mechanism), then you currently cannot use the single quote character within that literal.

Syntax is described here: https://docs.oracle.com/en/database/oracle/oracle-database/18/sqlrf/Literals.html#GUID-1824CBAA-6E16-4921-B2A6-112FB02248DA

Code Sample demonstrating the issue:

declare

  literal1 clob := q'!name LIKE '%DBMS_%%'!';
  literal2 clob := q'{SELECT * FROM employees WHERE last_name = 'Smith';}';
  literal3 clob := q'% test'test %';

  -- works
  literal1a clob := q'! test !';
  literal2a clob := q'{
    also multiple
    lines
  }';
  literal3a clob := q'% test abc %';

begin
  null;
end;
/

Running PMD through: Designer

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:bugPMD crashes or fails to analyse a file.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions