Reputation: 27
In the below code I have to add 4 values and divide by another value. It throws error
must declare scalar variable
Please help me to solve the issue.
// Passing the values
@i_TransferQuantity float,
@i_OnetimeCharge float,
@i_LoadingCharge float,
@i_UnLoadingCharge float,
@i_FreightCharge float,
@i_UnitPrice float
DECLARE @i_LoadingCharge, @i_UnLoadingCharge,
@i_FreightCharge, @i_UnitPrice,
@i_TotalUnitPrice, @i_TransferQuantity Float
SET @i_TotalUnitPrice = @i_LoadingCharge + @i_UnLoadingCharge +
@i_FreightCharge + @i_UnitPrice / @i_TransferQuantity
Upvotes: 0
Views: 1204
Reputation: 9572
Replace this:
// Passing the values
@i_TransferQuantity float,
@i_OnetimeCharge float,
@i_LoadingCharge float,
@i_UnLoadingCharge float,
@i_FreightCharge float,
@i_UnitPrice float
DECLARE @i_LoadingCharge, @i_UnLoadingCharge,
@i_FreightCharge, @i_UnitPrice,
@i_TotalUnitPrice, @i_TransferQuantity Float
with this:
DECLARE @i_LoadingCharge float, @i_UnLoadingCharge float,
@i_FreightCharge float, @i_UnitPrice float,
@i_TotalUnitPrice float, @i_TransferQuantity float
You'll have to reassign new names to the incoming parameters, though, as you cannot reuse the same names twice.
Upvotes: 0
Reputation: 637
You are re-declaring the same variables inside the stored procedure and they will remain uninitialized causing the error you are getting.
Upvotes: 1