i have compound sql query. need extract column names , aliases. names should printed side side corresponding each column names.
can above problem without connecting database?
query is:
select isnull(distinct coalesce(activityname, 'blank'), 'nullvalue') actname, activitypk primary, actcode code, startdt ‘start date’, (select ecode actbcodes act.actbcode_fk=bcodepk) ecode tbl_tmx_activity act output should be
isnull(distinct coalesce(activityname, 'blank'), 'nullvalue') actname activitypk primary actcode code startdt startdate (select ecode actbcodes act.actbcode_fk=bcodepk) ecode
yes, write own sql parser splits different parts of sql up. warn you, may exhausting task.
you can use antlr, parser/lexer tool. build recognize 'languages', sql. can see here, there sql grammars already. can use parse sql , desired results.
a solution might easier write more error-prone using regular expressions. if want have reliable, recommend antlr.
Comments
Post a Comment