April 21, 2009 at 6:43 pm
Hi ,
I have a really strange file. I will use an example to explain. The files has many records. The fields are customer_no, price_01, price_02, price_03 up to price_24.
The prices (price_01, price_02, etc...) are basic prices. There is a long program to calculate the final price. The previous programmer wrote 24 functions !!! So, if the formula to calculate the price change, I have to go in 24 functions...
What I'm trying to do is to pass 01, 02, 03, etc... and the functions will pick the fields in the database using price_ and the value.
I would like to know if you have an idea how to do it ?
Thanks
Real
April 21, 2009 at 6:50 pm
need more detail;
is there 24 different formulas, one for each column in your customer table, or is it the same calculation, but placed in 24 functions? show us two of the functions, say the one for column 1 and the next for column 2. we can compare them, see if they are doing the same thing, and work out some examples with that.
the devil is in the details...without giving us details, all we can do is speculate.
Lowell
April 21, 2009 at 8:19 pm
You understand the problem very well. The formulas are all the same in the 24 functions. The only thing that differ is the fields (price_01, 02, 03, etc).
Thanks
Real
April 21, 2009 at 8:22 pm
real (4/21/2009)
You understand the problem very well. The formulas are all the same in the 24 functions. The only thing that differ is the fields (price_01, 02, 03, etc).Thanks
Real
Awesome! Now, we still need to see the code.
April 21, 2009 at 8:46 pm
It's something like this
Declare @price decimal(10,2)
SET @price = price_01 FROM prices
SET @rebate = rebate_01 FROM rebates
SET @shipping = shipping_01 FROM Shipping
With "hundred" of formulas.
.
.
.
As you can see, only the 01 change. I would like to create only one function. Only the 01, 02, are changing
Thanks
Real
April 21, 2009 at 9:06 pm
kewl; once you post the actual functions, we'll be able to help; offhand, it looks like it could be replaced with a view that joins all your columns with joins to price, rebate and shipping tables, doing the calulations in the view for your actual costs instead, and getting rid of the functions altogether.
remember pseudo code can help explain the problem, but if you want a complex answer, throw out the pseudo code and give us the actual CREATE FUNCTION scripts.
Lowell
April 21, 2009 at 9:20 pm
real (4/21/2009)
It's something like thisDeclare @price decimal(10,2)
SET @price = price_01 FROM prices
SET @rebate = rebate_01 FROM rebates
SET @shipping = shipping_01 FROM Shipping
With "hundred" of formulas.
.
.
.
As you can see, only the 01 change. I would like to create only one function. Only the 01, 02, are changing
Thanks
Real
For the best help, read and follow the guidelines in this article: Forum Etiquette: How to post data/code on a forum to get the best help[/url].
For why you should, read this blog: The Flip Side.
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy