[Solved] Initializing Nested Table ( G-7110)
I'm initializing a nested table:
lst_chars IS TABLE OF VARCHAR2(40 CHAR);
list_tbl CONSTANT lst_chars := lst_chars ('FIRST', 'SECOND', 'THIRD' );
It compiles and works well, however StyleCOP is raising the Issue : Major G-7110 [Try to use a named notation ...], even if this is not a call to a function or program.
How can I circunvent this warning.
Thanks for your help
The following code does not report a G-7110 violation:
DECLARE TYPE lst_chars IS TABLE OF VARCHAR2(40 CHAR); list_tbl CONSTANT lst_chars := lst_chars ('FIRST', 'SECOND', 'THIRD'); BEGIN <<print_it>> FOR i IN 1..list_tbl.COUNT LOOP sys.dbms_output.put_line(list_tbl(i)); END LOOP print_it; END; /
However, PL/SQL Cop does not do a semantic analysis, therefore false positives are possible. You may use the NOSONAR marker to suppress the warning. Here's an example:
DECLARE l_something scott.mytype; co_a CONSTANT STRING := 'a'; BEGIN l_something := scott.mytype(co_a); -- NOSONAR: avoid G-7110 this is not a function call END; /
Another option is to disable the guideline check. See "Guideline skip list" in the SQL Developer preferences or the skip option in the command line utility. In SonarQube you may flag issues as false positives and they won't be reported on subsequent analysis.