zoukankan      html  css  js  c++  java
  • 存储过程——增删改(二)

    由于清明小长假缘故,中途几天博客呆滞,下面主要记录了存储过程实现简单的增删改操作:

    添加产品类型:

    -- =============================================
    -- Author:        <Author,,Name>
    -- Create date: <Create Date,,>
    -- Description:    <添加产品类型>
    -- =============================================
    CREATE PROCEDURE productTypeAdd
     (
     @Name nvarchar(50)
     )
    AS
    BEGIN
        INSERT [dbo].[productType]
        (
        Name
        )
        VALUES
        (
        @Name
        )
    END
    GO

    修改产品类型:

    -- =============================================
    -- Author:        <Author,,Name>
    -- Create date: <Create Date,,>
    -- Description:    <修改产品信息>
    -- =============================================
    CREATE PROCEDURE  productTypeUpdate
        (
        @id bigint,
        @name nvarchar(50),
        )
    AS
    BEGIN
        update [dbo].[productType]
        set name=@name,
        where id=@id
    END
    GO

    删除产品类型:

    -- =============================================
    -- Author:        <Author,,Name>
    -- Create date: <Create Date,,>
    -- Description:    <删除产品类型>
    -- =============================================
    CREATE PROCEDURE  productTypeDel
        (@ID BIGINT)
    AS
    BEGIN
        delete from [dbo].[productType]
        where  id=@ID;
    END
    GO

    查询所有产品信息:

    -- =============================================
    -- Author:        <Author,,Name>
    -- Create date: <Create Date,,>
    -- Description:    <查询所有产品信息>
    -- =============================================
    CREATE PROCEDURE QueryAllProduct
    
    AS
    BEGIN
        SELECT a.id,a.Name,a.Price,a.address,a.type,b.id,b.name FROM [dbo].[product] a
        inner join [dbo].[productType] b on a.type=b.id 
    END
    GO

    添加产品信息

    -- =============================================
    -- Author:        <Author,,Name>
    -- Create date: <Create Date,,>
    -- Description:    <添加产品信息>
    -- =============================================
    CREATE PROCEDURE productAdd
    (
    @Name nvarchar(50),
    @Price money,
    @Address nvarchar(50),
    @Type int
    )
    AS
    BEGIN
        insert [dbo].[product]
        (
        Name,
        Price,
        Address,
        Type
        )
        values
        (
        @Name,
        @Price,
        @Address,
        @Type
        )
    END
    GO

    删除产品信息

    -- =============================================
    -- Author:        <wangzhijun>
    -- Create date: <Create Date,,>
    -- Description:    <删除产品信息>
    -- =============================================
    CREATE PROCEDURE productDel
    @ID BIGINT
    AS
    BEGIN
        delete [dbo].[product]
        where id=@id
    END
    GO
  • 相关阅读:
    Flutter 中的基本路由
    BottomNavigationBar 自定义 底部导航条
    StatefulWidget 有状态组件
    flutte页面布局四
    flutter页面布局三
    flutter页面布局二
    设计模式-工厂方法模式
    设计模式-代理模式
    设计模式-装饰模式
    SpringBoot项目部署到服务器上,tomcat不启动该项目
  • 原文地址:https://www.cnblogs.com/tuqun/p/3652833.html
Copyright © 2011-2022 走看看