Ejemplo n.º 1
0
        public void AlterFunction()
        {
            var statement = Sql.AlterFunction("func00", true)
                            .ReturnValue(Parameter.Int())
                            .As(
                Sql.Return(1)
                );

            var command = Provider.GetCommand(statement);

            Assert.IsNotNull(command);
            Assert.AreEqual("DROP FUNCTION IF EXISTS `func00`;\r\nDELIMITER $$\r\nCREATE FUNCTION `func00`\r\n( )\r\nRETURNS INTEGER\r\nBEGIN\r\nRETURN 1;\r\nEND  $$;\r\nDELIMITER ;", command.CommandText);
        }
Ejemplo n.º 2
0
        public void AlterFunction()
        {
            var statement = Sql.AlterFunction("func01", true)
                            .Parameters(Parameter.Int("i01"), Parameter.Text("sd02"))
                            .Declarations(Parameter.Int("dec_val"))
                            .ReturnValue(Parameter.Int("$ret_val$"))
                            .As(
                Sql.Insert.Into("target_tbl").Values(Sql.Scalar(1), Sql.Scalar("function_test1"))
                );

            var command = Provider.GetCommand(statement);

            Assert.NotNull(command);
            Assert.Equal("CREATE OR REPLACE FUNCTION \"func01\" (  \"i01\" INTEGER, \"sd02\" TEXT )\r\nRETURNS INTEGER AS $ret_val$\r\nDECLARE\r\n\"dec_val\" INTEGER;\r\nBEGIN\r\nINSERT INTO \"target_tbl\" VALUES ( 1, 'function_test1' );\r\nEND;\r\n$ret_val$ LANGUAGE plpgsql;", command.CommandText);
        }
Ejemplo n.º 3
0
        public void AlterFunction()
        {
            var statement = Sql.AlterFunction("func00", true)
                            .Parameters(Parameter.Int("@i01"),
                                        Parameter.DateTime("@sd02"))
                            .ReturnValue(Parameter.Int())
                            .As(
                Sql.Select.Output(Sql.Star()).From("target_tbl"),
                Sql.Select.Output(Sql.Star()).From("source_tbl")
                );

            var command = Utilities.GetCommand(statement);

            Assert.IsNotNull(command);
            Assert.AreEqual(@"IF OBJECT_ID ( N'[func00]', N'FN' ) IS NULL
BEGIN;
EXEC (N' CREATE PROCEDURE [func00]
(
@i01 INT OUTPUT,
@sd02 DATETIME OUTPUT
)
AS
BEGIN;
SELECT * FROM [target_tbl];
SELECT * FROM [source_tbl];
END;
' );
END;
ELSE BEGIN;
EXEC (N' ALTER PROCEDURE [func00]
(
@i01 INT OUTPUT,
@sd02 DATETIME OUTPUT
)
AS
BEGIN;
SELECT * FROM [target_tbl];
SELECT * FROM [source_tbl];
END;
' );
END;", command.CommandText);
        }