Toad World® Forums

XPATH Loop Check

All,

I want to check every clause (i.e. select, from, where, order by, group by) should start on a new line, as should second and subsequent occurrences of: column names table names SQL reserved words using Toad Code Analysis (Code Expert) rule, any idea how to do this?

//SELECT[(descendant::SELECT_ITEM)[1]/@line =(descendant::SELECT_ITEM)[2]/@line or (descendant::SELECT_ITEM)[2]/@line =(descendant::SELECT_ITEM)[3]/@line] ,
//SELECT[(descendant::TABLE_REF)[1]/@line =(descendant::TABLE_REF)[2]/@line or (descendant::TABLE_REF)[2]/@line =(descendant::TABLE_REF)[3]/@line] ,
//SELECT[(descendant::INTO_LIST/QNAME)[1]/@line =(descendant::INTO_LIST/QNAME)[2]/@line or (descendant::INTO_LIST/QNAME)[2]/@line =(descendant::INTO_LIST/QNAME)[3]/@line]

I tried writing this, but my problem is how would I found how many columns in each clause, and check none of column, table list in same line.

Below is example how rule should to hit

–This should be fine

SELECT ename
, enumber
, dob
INTO lv_varchar
,ln_number
,ln_count
FROM employee e1
, employee2 e2
WHERE ename=‘ANIL’;

SELECT ename
, enumber
, dob
INTO lv_varchar ,ln_number
,ln_count
FROM employee e1
, employee2 e2
WHERE ename=‘ANIL’;

SELECT ename
, enumber
, dob
INTO lv_varchar
,ln_number
,ln_count
FROM employee e1 , employee2 e2 – should hit, two are in one row
WHERE ename=‘ANIL’ ;

SELECT ename, enumber – should hit, two are in one row
, dob
INTO lv_varchar
,ln_number
,ln_count
FROM employee e1
, employee2 e2
WHERE ename=‘ANIL’ ;

any clue is appricated

Regards

Anil

You should be using Toad’s formatter and formatter options to accomplish this. This is not something code analysis should or would perform. Code Analysis is for best practices on programming - not for formatting. So Main Menu -> View-> Toad Options, then inside options screen choose Formatter, now look through all the many settings to adjust this. Also note that a pop-up with example PL/SQL code of what you selections will cause. I think what you want is doable - but not a single, simple check box. I think you’ll need to look under many dfferent categories/areas to find all the check boxes or selection to effect your desired end result.

Bert,

You are correct, but my requirement is something different

Once developer completes coding standards, and formatting we have a quality process code should pass all rules (including formatting )so I want avoid manual checking

As part of Quality check, I want to automate Quality process using Code Xpert, so just wondered how this is possible? Code Xpert does not have any help content to achieve this.

Aha - thanks for educating me on your need. I’ll need to think some on this. You may well be asking for something we did not consider.