Skip to Main Content

SQL Developer

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Arbori Code : trying to identify TO_CHAR() with single parameter

Mike KutzMay 28 2019 — edited May 29 2019

I'm trying to develop some arbori code in order to highlight "bad usage of TO_DATE()"

For my first case (of "bad usage"), I'm trying to highlight all calls to TO_DATE() that have only a single parameter.  My test is currently narrowed down to a string_literal.

The first problem I ran into was "how do you identify all instances of TO_DATE?".

I can pick out one call to TO_DATE but I can't pick out all of them.  What is the correct node classification I should be using?

The second problem was trying to identify the TO_DATE as having a single parameter.  (i've simplified my Use Case to search for string_literals only)

Some how I keep screwing this one up.

Where is my logic going wrong?

Many thanks

MK

In the Arbori Editor, I've tried variations of the following:  (yes, the "->" line is missing for "highlighting code" but I'm trying to get this correct)

PlSqlCustom3:

  ?name = 'to_date'

& op^^ = node

& name^ = node

& [op) '('

& [node) function_call

--& ( [pel) paren_expr_list

--& pel^ = node

--& name+1 = pel

--& [op) '('

--& op^ = pel

--& op^^ = node )

--& op^^ = node

--& [sl) string_literal

--& [cp) ')'

--& op+1 = sl

--& sl+1 = cp

;

My test PL/SQL code:

declare

  d date;

begin

  -- identifies as a function_call

  d := to_date( '5-may-19' );

  -- identifies as a datetime_literal

  -- should not highlight (unless Arbori can identify the usage of RR)

  -- I don't think Arbori can identify string literals that contain a specific text string, but highly desired

  d := to_date( '5-may-19', 'dd-mon-rr' );

  -- identifies as user_defined_function

  select to_date( '5-may-19') into d

  from dual;

end;

This post has been answered by Vadim Tropashko-Oracle on May 29 2019
Jump to Answer

Comments

Post Details

Added on May 28 2019
1 comment
376 views