Solved

Decimal places not returning from a stored procedure

Posted on 2001-07-11
9
412 Views
Last Modified: 2012-06-27
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_procedure.Parameters("@result4")

%><td><%Response.Write(formatnumber(result4,2))%></td><%

I have tried changing the data type in the stored to float, numeric but none work.

Can anyone help??
0
Comment
Question by:obicham
  • 4
  • 3
  • 2
9 Comments
 
LVL 11

Expert Comment

by:Otana
ID: 6272822
you have declared your output variable (@result4) as an integer, therefore you will not get any decimalplaces returned.

try this: @return4 numeric(13,10)
0
 
LVL 11

Expert Comment

by:Otana
ID: 6272832
I meant @result4 off course, sorry...
0
 

Author Comment

by:obicham
ID: 6272847
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
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 11

Expert Comment

by:Otana
ID: 6272881
set @discinc = (select Approved_Disc_Inc from pr_misc)

what type of field is Approved_Disc_Inc? And what does it contain?
0
 

Author Comment

by:obicham
ID: 6272927
It is decimal(5) and it contains the value 1.75
0
 
LVL 11

Expert Comment

by:Otana
ID: 6272949
select Approved_Disc_Inc from pr_misc

does this return a single value? or multiple records? can you post more of your stored procedure?
0
 
LVL 7

Accepted Solution

by:
John844 earned 50 total points
ID: 6273202
whenyou tried changing the datatype as mentioned above, did you also change the datatype of your command parameter?
0
 
LVL 7

Expert Comment

by:John844
ID: 6273214
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)
0
 

Author Comment

by:obicham
ID: 6276103
This is indeed where I was going wrong.

Thanks very much.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JQuery Date Time picker not showing 29 134
Adding Datediff to staistics page 2 57
If-Then-Else ASP problem 6 63
Select only the top record in a left join 13 37
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question