obicham
asked on
Decimal places not returning from a stored procedure
I have a stored procedure which should be returning a percentage back to the ASP page.
The problem is it is rounding up to the nearest whole number and not returning the decimal places.
The relevant parts of the stored procedure are as follows(the variable used to return the percentage is @result4):
CREATE PROCEDURE sp_highlevelsummaryrpt
@result4 int output
AS
declare @discinc decimal
if (@discinc is null)
begin
set @discinc = '0'
end
set @discinc = (select Approved_Disc_Inc from pr_misc)
set @result4 = @discinc
select @result4
In the ASP page, I am showing the variable on the page as follows:
result4 = cmd_Execute_stored_procedu re.Paramet ers("@resu lt4")
%><td><%Response.Write(for matnumber( result4,2) )%></td><%
I have tried changing the data type in the stored to float, numeric but none work.
Can anyone help??
The problem is it is rounding up to the nearest whole number and not returning the decimal places.
The relevant parts of the stored procedure are as follows(the variable used to return the percentage is @result4):
CREATE PROCEDURE sp_highlevelsummaryrpt
@result4 int output
AS
declare @discinc decimal
if (@discinc is null)
begin
set @discinc = '0'
end
set @discinc = (select Approved_Disc_Inc from pr_misc)
set @result4 = @discinc
select @result4
In the ASP page, I am showing the variable on the page as follows:
result4 = cmd_Execute_stored_procedu
%><td><%Response.Write(for
I have tried changing the data type in the stored to float, numeric but none work.
Can anyone help??
I meant @result4 off course, sorry...
ASKER
That's a very good point but unfortunately it still doesn't work for some reason.
I tried declaring the output variable as decimal and a float but that won't work either
I tried declaring the output variable as decimal and a float but that won't work either
set @discinc = (select Approved_Disc_Inc from pr_misc)
what type of field is Approved_Disc_Inc? And what does it contain?
what type of field is Approved_Disc_Inc? And what does it contain?
ASKER
It is decimal(5) and it contains the value 1.75
select Approved_Disc_Inc from pr_misc
does this return a single value? or multiple records? can you post more of your stored procedure?
does this return a single value? or multiple records? can you post more of your stored procedure?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
does the stored procedure display the proper values when you run it from query analyser?
I would also change this line to avoid any future problems if more records are added.
set @discinc = (select Approved_Disc_Inc from pr_misc)
to
set @discinc = (select TOP 1 Approved_Disc_Inc from pr_misc)
I would also change this line to avoid any future problems if more records are added.
set @discinc = (select Approved_Disc_Inc from pr_misc)
to
set @discinc = (select TOP 1 Approved_Disc_Inc from pr_misc)
ASKER
This is indeed where I was going wrong.
Thanks very much.
Thanks very much.
try this: @return4 numeric(13,10)