Originally posted by hvbtup July 22, 2024
I'm using PMD with the PL/SQL language.
Rule: TomKytesDespair
The following construct causes an exception:
create or replace procedure x
is
v_cursor number;
begin
v_cursor := DBMS_SQL.open_cursor;
dbms_output.put_line('Blah');
exception
WHEN OTHERS THEN
IF DBMS_SQL.is_open(v_cursor) THEN
DBMS_SQL.close_cursor(v_cursor);
END IF;
DBMS_OUTPUT.Put_Line('Blah');
DBMS_OUTPUT.Put_Line(SQLERRM);
end;
/
Actually, my code is a bit more complex and in a package, but th
WARN [PmdThread 16] (RuleApplicator.java:114) - Exception applying rule TomKytesDespair on file C:\svn\core\trunk\install\ddl\statistik.pck, continuing with next rule
net.sourceforge.pmd.lang.rule.xpath.PmdXPathException: net.sf.saxon.trans.XPathException: A sequence of more than one item is not allowed as the first argument of fn:upper-case() ("DBMS_OUTPUT.PUT_LINE", "DBMS_OUTPUT.PUT_LINE")
Exception Context:
[1:Kind=Type error]
[2:Phase=EVALUATION]
[3:Expression=//ExceptionHandler[QualifiedName/@Image='OTHERS' and upper-case(Statement/UnlabelledStatement/Expression/@Image)='NULL']]
[4:Version=3.1]
[5:Location in expr=; SystemID: ; Line#: 1; Column#: 74]
[6:Rule=TomKytesDespair]
[7:Rule applied on node=!debug only! [ExceptionHandler:2023:9]WHEN OTHERS THEN
IF DBMS_SQL.is_open(v_cursor) THEN
DBMS_SQL.close_cursor(v_cursor);
END IF;
DBM(truncated)]
---------------------------------
at net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery.wrapException(SaxonXPathRuleQuery.java:152)
at net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery.evaluate(SaxonXPathRuleQuery.java:145)
at net.sourceforge.pmd.lang.rule.xpath.XPathRule.apply(XPathRule.java:101)
at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex(RuleApplicator.java:77)
at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.apply(RuleApplicator.java:57)
at net.sourceforge.pmd.lang.rule.internal.RuleSets.apply(RuleSets.java:155)
at net.sourceforge.pmd.lang.impl.PmdRunnable.processSource(PmdRunnable.java:140)
at net.sourceforge.pmd.lang.impl.PmdRunnable.run(PmdRunnable.java:80)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: net.sf.saxon.trans.XPathException: A sequence of more than one item is not allowed as the first argument of fn:upper-case() ("DBMS_OUTPUT.PUT_LINE", "DBMS_OUTPUT.PUT_LINE")
at net.sf.saxon.expr.CardinalityCheckingIterator.typeError(CardinalityCheckingIterator.java:113)
at net.sf.saxon.expr.CardinalityCheckingIterator.<init>(CardinalityCheckingIterator.java:71)
at net.sf.saxon.expr.CardinalityChecker.checkCardinality(CardinalityChecker.java:258)
at net.sf.saxon.expr.CardinalityChecker$CardinalityCheckerElaborator.lambda$elaborateForPull$0(CardinalityChecker.java:506)
at net.sf.saxon.expr.elab.PullElaborator.lambda$elaborateForItem$1(PullElaborator.java:54)
at net.sf.saxon.expr.elab.PullElaborator.lambda$elaborateForUnicodeString$3(PullElaborator.java:76)
at net.sf.saxon.functions.UpperCase$UpperCaseFnElaborator.lambda$elaborateForUnicodeString$0(UpperCase.java:61)
at net.sf.saxon.expr.elab.StringElaborator.lambda$elaborateForItem$2(StringElaborator.java:57)
at net.sf.saxon.expr.ValueComparison$ValueComparisonElaborator.lambda$elaborateForBoolean$4(ValueComparison.java:608)
at net.sf.saxon.expr.AndExpression$AndElaborator.lambda$elaborateForBoolean$0(AndExpression.java:212)
at net.sf.saxon.expr.elab.BooleanElaborator.lambda$elaborateForPull$0(BooleanElaborator.java:25)
at net.sf.saxon.expr.FilterExpression$FilterExprElaborator$PositionalFilteredIterator.next(FilterExpression.java:1330)
at net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery.evaluate(SaxonXPathRuleQuery.java:128)
... 11 more
The main message is from Saxon: A sequence of more than one item is not allowed as the first argument of fn:upper-case() ("DBMS_OUTPUT.PUT_LINE", "DBMS_OUTPUT.PUT_LINE")
How can the rule be adapted to avoid the exception?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4