Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DTP » Accessing Result columns after parsing using SQLQueryParser(Accessing Result columns after parsing using SQLQueryParser)
Accessing Result columns after parsing using SQLQueryParser [message #869135] Thu, 03 May 2012 01:40
Aditya Wagle is currently offline Aditya Wagle
Messages: 7
Registered: November 2011
Junior Member
I am trying to use the SQLQueryParser to parse a query statement and want to gather the result columns and their data type.

Currently I can successfully get the column name however the data type is not populated. I am not sure how I can pass the connection profile. I tried extracting the Database object from IConnectionProfile and passing it to StatementHelper but to no avail.

This is what I am trying right now:

Database db = getDatabaseForProfile(connection);
			StatementHelper helper = new StatementHelper(db);
			
			SQLQueryParserManager parserManager = SQLQueryParserManagerProvider.getInstance().getParserManager(db.getVendor(), db.getVersion());
			QuerySelectStatement result = null;
			try {
				result = (QuerySelectStatement) parserManager.parseQuery(statement).getQueryStatement();
			} catch (SQLParserException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SQLParserInternalException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			List columnList = helper.getEffectiveResultColumns(result);
			
			Iterator<ValueExpressionColumn> columnIterator = columnList.iterator();
			while(columnIterator.hasNext()){
				ValueExpressionColumn column = columnIterator.next();
				System.out.println("Column name is "+column.getName());
				System.out.println("Column datatype is "+column.getDataType());
			}


Any help is appreciated!

-Aditya
Previous Topic:"execute all" always splits up statements at semicolon
Next Topic:"NLS missing" messages on Ubuntu
Goto Forum:
  


Current Time: Sat Oct 25 22:58:11 GMT 2014

Powered by FUDForum. Page generated in 0.02724 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software