public static SqlQueryExpressionItem BuildColumn(IContext context, PlSqlParser.SelectedElementContext selectedElement) { string alias = null; if (selectedElement.column_alias() != null && !selectedElement.column_alias().IsEmpty) { alias = Name.Simple(selectedElement.column_alias()); } SqlQueryExpressionItem column; if (selectedElement.expression() != null && !selectedElement.expression().IsEmpty) { column = new SqlQueryExpressionItem( SqlParseExpression.Build(context, selectedElement.expression()), alias); } else if (selectedElement.selectedColumn() != null && !selectedElement.selectedColumn().IsEmpty) { bool glob = selectedElement.selectedColumn().glob != null; ObjectName name = Name.Select(selectedElement.selectedColumn().objectName(), glob); var exp = SqlExpression.Reference(name); column = new SqlQueryExpressionItem(exp, alias); } else { throw new ParseCanceledException(); } return(column); }
public static SelectColumn BuildColumn(PlSqlParser.SelectedElementContext context) { string alias = null; if (context.column_alias() != null && !context.column_alias().IsEmpty) { alias = Name.Simple(context.column_alias()); } SelectColumn column; if (context.expression() != null && !context.expression().IsEmpty) { column = new SelectColumn(Expression.Build(context.expression()), alias); } else if (context.selectedColumn() != null && !context.selectedColumn().IsEmpty) { bool glob = context.selectedColumn().glob != null; ObjectName name = Name.Select(context.selectedColumn().objectName(), glob); var exp = SqlExpression.Reference(name); column = new SelectColumn(exp, alias); } else { throw new ParseCanceledException(); } return(column); }