PL/SQL parse errors

Sonarqube Enterprise edition, loading a folder of .SQL files with the Scanner for Windows option.

I get multiple errors reported in the Command window when running the Scanner which appear to refer to code lines with white space in them.

Things like this

declare

@foo int;

Appears to give an error where there shouldn’t be one. I saw a previous post from 2020 where the OP and others identified that the parser was following the documentation and not what the Oracle compiler allows, i.e. optional clauses.

I turned on verbose feedback with -X but I’ve got no further.

Is there any guidance? (I don’t currently have admin access on our server, so if there is a setting to exclude whitespace or line-breaks, I haven’t seen it yet)

Hey there.

As requested in the template post, what version of SonarQube are you using?

Hi, sorry as a new user I wasn’t aware that that template had to be completed on every new post, lesson learnt.
The answer is 9.0.1.46107 Enterprise

Regards
Simon

Thanks!

The PL/SQL analyzer has been updated in SonarQube v9.9 LTS – but I can’t say for sure that this issue has been addressed.

In any case, your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

9.0.1 → 9.9.1 → 10.2 (last step optional)

You may find these resources helpful:

If you have questions about upgrading, feel free to open a new thread for that here.

I would suggest:

  • Upgrading to a supported version
  • If the analysis still gives an error, please upload a single PL/SQL file where you encounter this parsing error so that it can be easily reproduced on our side.

Hi,

The declaration “@foo int;” is not valid in Oracle PL/SQL and will not compile on the Oracle Database. It appears to be T-SQL code, which is used in MS SQL Server.

If that is the case, you will need to modify the “File Suffixes” properties either on the server or by passing it to the SonarScanner to analyze the file with the correct analyzer, e.g. -Dsonar.plsql.file.suffixes= -Dsonar.tsql.file.suffixes=sql

1 Like

:pray: thank you @felipebz

Hi, sorry as a new user I wasn’t aware that that template had to be completed on every new post, lesson learnt.
The answer is 9.0.1.46107 Enterprise

Regards
Simon

Hi Felipe, sorry that’s my background coming out from the transact-SQL world…

My point is that the PL/SQL parser reports issues with white space/blank lines between DECLARE statements and the variables/data types.