public override SqlExpression VisitTrimFunction(PlSqlParser.TrimFunctionContext context) { var arg1 = SqlParseExpression.Build(context.concatenationWrapper()); var part = "both"; if (context.LEADING() != null) { part = "leading"; } else if (context.TRAILING() != null) { part = "trailing"; } else if (context.BOTH() != null) { part = "both"; } var toTrim = " "; if (context.quoted_string() != null) { toTrim = SqlParseInputString.AsNotQuoted(context.quoted_string()); } var arg2 = SqlExpression.Constant(SqlObject.String(part)); var arg3 = SqlExpression.Constant(SqlObject.String(toTrim)); return(SqlExpression.Function("SQL_TRIM", new SqlExpression[] { arg1, arg2, arg3 })); }
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); }