Beispiel #1
0
        public void Test_11_CreateProcedure()
        {
            DBParam custid  = DBParam.Param("cust", DbType.Int32);
            DBParam orderid = DBParam.Param("id", DbType.Int32, ParameterDirection.Input);
            DBParam name    = DBParam.Param("name", DbType.String, 50, ParameterDirection.Input);

            DBQuery create = DBQuery.Create.StoredProcedure("dbo", "ChangeOrderItemCustomer")
                             .WithParams(orderid, name)
                             .As(
                DBQuery.Declare(custid),

                DBQuery.Select().TopN(1)
                .Field(DBAssign.Set(custid, DBField.Field("customerid")))
                .From("Orders")
                .WhereFieldEquals("order_id", orderid),

                DBQuery.Update("OrderItems")
                .Set("customerid", custid)
                .Set("customername", name)
                .WhereFieldEquals("orderid", orderid)
                );

            this.OutputAndValidate(create, " Create Procedure ChangeOrderItemCustomer");
        }