protected virtual SqlStatement VisitCreateFunction(CreateFunctionStatement statement) { var body = statement.Body; if (body != null) { // TODO: Maybe the body should be generic to support this model body = (PlSqlBlockStatement)VisitStatement(body); } return(new CreateFunctionStatement(statement.FunctionName, statement.ReturnType, statement.Parameters, body) { ReplaceIfExists = statement.ReplaceIfExists }); }
public static void WithArguments() { var body = new PlSqlBlockStatement(); body.Statements.Add(new AssignVariableStatement(SqlExpression.VariableReference("a"), SqlExpression.Constant(3))); body.Statements.Add(new ReturnStatement(SqlExpression.VariableReference("a"))); var statement = new CreateFunctionStatement(ObjectName.Parse("SYS.func1"), PrimitiveTypes.Integer(), new[] { new RoutineParameter("a", PrimitiveTypes.Integer()), }, body); var sql = statement.ToString(); var expected = new SqlStringBuilder(); expected.Append("CREATE FUNCTION SYS.func1(a INTEGER IN NOT NULL) "); expected.AppendLine("RETURN INTEGER IS"); expected.AppendLine(" BEGIN"); expected.AppendLine(" :a := 3"); expected.AppendLine(" RETURN :a"); expected.Append(" END"); Assert.AreEqual(expected.ToString(), sql); }
protected virtual SqlStatement VisitCreateFunction(CreateFunctionStatement statement) { var body = statement.Body; if (body != null) // TODO: Maybe the body should be generic to support this model body = (PlSqlBlockStatement) VisitStatement(body); return new CreateFunctionStatement(statement.FunctionName, statement.ReturnType, statement.Parameters, body) { ReplaceIfExists = statement.ReplaceIfExists }; }