none
Procedure or function has too many arguments specified.

    Pregunta

  • hello all,

    i am writing a program that is adding some details using OrderDetail_Insert stored procedure.

    When i am trying to add it is giving error Procedure or function OrderDetail_Insert has too many arguments specified.

    Stored procedure is under...

    set ANSI_NULLS ON

    set QUOTED_IDENTIFIER ON

    GO

    ALTER procedure [dbo].[OrderDetail_Insert]

    @ItemCatName as varchar(50),

    @ItemSubCatName as varchar(50),

    @PartNo as varchar(50),

    @Description as varchar(max),

    @Price as float,

    @Quantity as float,

    @Total as float,

    @OrderID as int,

    @Brand as varchar(50),

    @Discount as float,

    @UnitPrice as float

    as

    set @OrderID = (select max(ID)+1  from [Order])

    insert into OrderDetail(ItemCatName,ItemSubCatName,PartNo,Description,Price,Quantity,Total,Brand,OrderID,Discount,UnitPrice)

    values(@ItemCatName,@ItemSubCatName,@PartNo,@Description,@Price,@Quantity,@Total,@Brand,@OrderID,@Discount,@UnitPrice)


    Can anyone guide me where exactly is problem ???


    Thanks

    Jazaib Hussain


    viernes, 25 de mayo de 2012 10:55

Respuestas

  • Hi,

    Do as follows

    set ANSI_NULLS ON

    set QUOTED_IDENTIFIER ON

    GO

    ALTER procedure [dbo].[OrderDetail_Insert]

    @ItemCatName as varchar(50),

    @ItemSubCatName as varchar(50),

    @PartNo as varchar(50),

    @Description as varchar(max),

    @Price as float,

    @Quantity as float,

    @Total as float,

    @OrderID as int,

    @Brand as varchar(50),

    @Discount as float,

    @UnitPrice as float

    as

    BEGIN

    set @OrderID = (max(ID)+1)  from [Order])

    insert into OrderDetail(ItemCatName,ItemSubCatName,PartNo,Description,Price,Quantity,Total,Brand,OrderID,Discount,UnitPrice)

    values(@ItemCatName,@ItemSubCatName,@PartNo,@Description,@Price,@Quantity,@Total,@Brand,@OrderID,@Discount,@UnitPrice)

    END

    PS.Shakeer Hussain

    • Marcado como respuesta Jazaib Hussain sábado, 26 de mayo de 2012 9:39
    viernes, 25 de mayo de 2012 11:26

Todas las respuestas

  • The procedure looks okay. How do you invoke it?
    viernes, 25 de mayo de 2012 11:22
  • Hi,

    Do as follows

    set ANSI_NULLS ON

    set QUOTED_IDENTIFIER ON

    GO

    ALTER procedure [dbo].[OrderDetail_Insert]

    @ItemCatName as varchar(50),

    @ItemSubCatName as varchar(50),

    @PartNo as varchar(50),

    @Description as varchar(max),

    @Price as float,

    @Quantity as float,

    @Total as float,

    @OrderID as int,

    @Brand as varchar(50),

    @Discount as float,

    @UnitPrice as float

    as

    BEGIN

    set @OrderID = (max(ID)+1)  from [Order])

    insert into OrderDetail(ItemCatName,ItemSubCatName,PartNo,Description,Price,Quantity,Total,Brand,OrderID,Discount,UnitPrice)

    values(@ItemCatName,@ItemSubCatName,@PartNo,@Description,@Price,@Quantity,@Total,@Brand,@OrderID,@Discount,@UnitPrice)

    END

    PS.Shakeer Hussain

    • Marcado como respuesta Jazaib Hussain sábado, 26 de mayo de 2012 9:39
    viernes, 25 de mayo de 2012 11:26
  • The line you have below will not work

    set @OrderID = (max(ID)+1)  from [Order])

    What you need is :-

    select @OrderID = (max(ID)+1) from [Order]

    This will work fine on 2008

    lunes, 11 de junio de 2012 14:31