Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there something like EVALUATE() fox function ?
Message
From
26/06/2006 12:29:33
 
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
01131426
Message ID:
01131734
Views:
22
Perfect!
I will use it.
Thanks.



>>Sure, more details:
>>
>>I have a Fee Setup table in order to know how to calculate Customer fees for a given transaction, based on ranges of transaction amounts, for example:
>>
>>
>>To Country      From $      To  $        Calculate Formula
>>Puerto Rico       1.00        100.00      @yUsaAmt * 0.05
>>Puerto Rico     100.01       1000.00      (@yUsaAmt * 0.05) + @ySpecialChrg
>>
>>And so on for many countries and ranges and other possible variables.
>>
>>During my loop, I am scanning a set of transactions and have to calculate the Fee for every transaction, based on the formula.
>>
>>From my transaction record I will pre-define values for @yUsaAmt and @SpecialChrg, Example:
>>
>>Trans #1        Amount $      Special Charge    Fee Formula $
>>0001              50.00            0.00            2.50
>>0002             150.00            3.00            10.50    ( $7.5 + $3.00)
>>
>>The way to calculate the fee is dynamic, but parameters may be 1 or 2 or 3 or more. I just pre-define a set of possible variables but i don't know how many of them will be used in the formula, so I can't create a specific string to be processed through sp_executesql. In Fox we used to do it with just Evaluate() function.
>>
>>I hope to be clear, and thank you again.
>>
>>
>Hi Juan,
>
>You can build something similar to VFP TEXRMERGE
>
>DECLARE
>	@expr 		varchar(100),
>	@sql 		nvarchar (200),
>	@yUsaAmt 	money,
>	@ySpecialChrg 	money,
>	@yResult 	money;
>	
>SET @expr = '(<<@yUsaAmt>> * 0.05) + <<@ySpecialChrg>>';
>
>SET @yUsaAmt 	  = 150.00;
>SET @ySpecialChrg = 3.00;
>
>SET @expr = REPLACE(@expr, '<<@yUsaAmt>>', CAST(@yUsaAmt AS varchar(20)));
>SET @expr = REPLACE(@expr, '<<@ySpecialChrg>>', CAST(@ySpecialChrg AS varchar(20)));
>
>SET @sql = N'SET @yResult = ' + @expr;
>EXECUTE sp_executesql @sql,
>		N'@yResult money OUTPUT',
>		@yResult OUTPUT;
>
>SELECT @yResult;
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform