)
throws StandardException
{
Parser p;
ValueNode clauseTree;
LanguageConnectionContext lcc = getLanguageConnectionContext();
CompilerContext compilerContext = getCompilerContext();
/* Get a Statement to pass to the parser */
/* We're all set up to parse. We have to build a compilable SQL statement
* before we can parse - So, we goober up a VALUES defaultText.
*/
String select = "SELECT " + clauseText + " FROM " + td.getQualifiedName();
/*
** Get a new compiler context, so the parsing of the select statement
** doesn't mess up anything in the current context (it could clobber
** the ParameterValueSet, for example).
*/
CompilerContext newCC = lcc.pushCompilerContext();
p = newCC.getParser();
/* Finally, we can call the parser */
// Since this is always nested inside another SQL statement, so topLevel flag
// should be false
StatementNode qt = p.parseStatement(select);
if (SanityManager.DEBUG)
{
if (! (qt instanceof CursorNode))
{
SanityManager.THROWASSERT(
"qt expected to be instanceof CursorNode, not " +
qt.getClass().getName());
}
CursorNode cn = (CursorNode) qt;
if (! (cn.getResultSetNode() instanceof SelectNode))
{
SanityManager.THROWASSERT(
"cn.getResultSetNode() expected to be instanceof SelectNode, not " +
cn.getResultSetNode().getClass().getName());
}
}
clauseTree = ((ResultColumn)
((CursorNode) qt).getResultSetNode().getResultColumns().elementAt(0)).
getExpression();
lcc.popCompilerContext(newCC);
return clauseTree;
}