Important Announcement

This forum will be discontinued.

The creation of new topics is disabled.

Please open GitHub issues for the corresponding topics/products in the following Trivadis repositories:

A lot of users have already a GitHub account and the management of the issues is better than in this forum. For example, closing a forum topic is never related to a product change. Closing a GitHub issue for an accepted bug means that the bug is fixed. This should simplify the work for all involved parties.

See this blog post for more information.

Thank you for your understanding.

Notifications
Clear all

[Solved] Initializing Nested Table ( G-7110)

2 Posts
2 Users
1 Reactions
7,162 Views
0
Topic starter

Hi There.

 

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

 

Diego.

1 Answer
1

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.

 

diordonez Topic starter 18/05/2017 3:10 pm

Thank you.

I didn't want to disable the TAG 7110 since that one is very handy.

The NOSONAR tip definitely did the job.

In anycase stylecop reported the issue G-0000, do not use NOSONAR, but I disabled that tag and now my code is pristine.

 

Best regards

Diego.