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