-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[plsql] Parse error for operator in TRIM function call #5522
Comments
Hi @Ferada , thanks for reporting! the current parser interprets It seems, there is another TRIM function in PL/SQL, which is called TRIM Collection Method. Is this correct? I'll try to adjust the grammar to allow an arbitrary expression as a function argument. Unfortunately, the TRIM Collection Method is not clearly specified: in Btw. I guess |
That looks like it to me. Which also makes my examples above wrong, because they'd be using the function call where no arbitrary expression is valid. So this issue should only apply to the collection method after all, didn't realise there's a difference.
Which makes sense, you'd want to be able to specify a fixed number or an expression?
Yeah, sounds correct. What a pain that that's a function call. |
yes, the collection method calls must be qualified (https://docs.oracle.com/en/database/oracle/oracle-database/23/lnpls/qualified-names-and-dot-notation.html), so the example should be more like: function distinguishXML() return text is
begin
collection_name.trim(x + y);
return 'done';
end;
/ |
I tested it again now with the real thing (via docker from https://github.com/gvenzl/oci-oracle-free): a numeric expression seems to be valid for TRIM, e.g. this works fine in sqlplus: docker exec -i oracle-test sqlplus -S system/changeit <<EOF
create or replace package p_utils is
function distinguishXML(x in number, y in number) return varchar;
end;
/
create or replace package body p_utils is
function distinguishXML(x in number, y in number) return varchar is
begin
return trim(x + y);
end;
end;
/
SHOW ERRORS
SET SERVEROUTPUT ON
DECLARE
BEGIN
DBMS_OUTPUT.PUT_LINE(p_utils.distinguishXML(1, 2));
END;
/
EOF similarly, the following expressions in a select are all valid:
So, I'm going to adjust the grammar to allow this. Note, we currently require "from dual" for these selects, but this seems to be not needed anymore since Oracle 23 (see https://oracle-sql-features.github.io/guide/latest/versions/23.2/sql/select-without-from.html ). |
Affects PMD Version:
Description:
A function call in a function definition fails to parse when there's a
+
operator as one, or the, argument. Presumably happens with any other operators as well.The full example is https://github.com/Qualtagh/OracleDBUtils/blob/master/p_utils.9.sql#241.
Exception Stacktrace:
Code Sample demonstrating the issue:
Similarly,
select trim(x + y) from foo;
also fails with the same error, which looks like the same situation to me and should be valid?Running PMD through: CLI
The text was updated successfully, but these errors were encountered: