Insert a Value from an Exec within a stored procedure

Last Post 28 Nov 2011 11:06 PM by Bjorn Lonneville. 1 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
BlackGateTechnology
New Member
New Member

--
28 Nov 2011 09:00 AM
I am trying to get a price of an item then inserting into a table. When I test the individual sp's they work fine but when I do an exec in the procedure it will not get the price.

SP

Create procedure [dbo].[proc_PurchaseDetail_Insert]

@PurchaseIdint,
@PurchaseItemIdint,
@Qtyint

As



DECLARE @Priceasint

EXEC @Price = proc_PurchaseItem_GetPrice @PurchaseItemId



INSERT INTO tblPurchaseDetail
(
PurchaseId,
PurchaseItemId,
Qty,
Price
)
     VALUES
(
@PurchaseId,
@PurchaseItemId,
@Qty,
@Qty * @Price
)

THANK YOU FOR YOUR HELP
Bjorn Lonneville
New Member
New Member

--
28 Nov 2011 11:06 PM

Hi,

 

With me this code is working fine on my computer:

 

Create procedure [dbo].[proc_PurchaseDetail_Insert]

      @PurchaseId int,

      @PurchaseItemId int,

      @Qty int

As

 

DECLARE @Price int

 

EXEC proc_PurchaseItem_GetPrice@PurchaseItemId, @Price output

 

INSERT INTO tblPurchaseDetail

(

      PurchaseId,

      PurchaseItemId,

      Qty,

      Price

)

  VALUES

(

      @PurchaseId,

      @PurchaseItemId,

      @Qty,

      @Qty * @Price

)

 

If this doesn’t work provide me also the code of your “proc_PurchaseItem_GetPrice” procedure.



Acceptable Use Policy
---