| Author |
Topic |
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2005-04-06 : 02:21:32
|
| i'm trying to convert some asp code to be done in a stored procedurecan someone help me with syntax for a do while loopthe variables would be brought into the sp as this will be done before adding the recordfor example how would I do the following:do while mypercent>.95 if cdbl(price1)>2000000 then newprice=1100000 if cdbl(price1)> 100000< 20000 then newprice=10000 loop |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-04-06 : 02:30:19
|
| while mypercent>.95Beginif cdbl(price1)>2000000 newprice=1100000if cdbl(price1)> 100000< 20000 newprice=10000 ...Increare or Decrease the value of mypercentendMadhivananFailing to plan is Planning to fail |
 |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2005-04-06 : 02:49:11
|
| Thanks for your help.I am getting an error --incorrect syntax near < |
 |
|
|
AndyB13
Aged Yak Warrior
583 Posts |
Posted - 2005-04-06 : 02:54:12
|
Why do you need to use a loop, what exactly are you trying to do?You could possibly use a CASE statement insteadEgCASE WHEN (mypercent > .95 AND price1 > 2000000) THEN 1100000 WHEN (mypercent > .95 AND (price1 BETWEEN 20000 AND 100000)) THEN 10000 WHEN (mypercent > .95 AND price1 > 100000 AND price1 < 20000) THEN 10000 ELSE price1 END AS newprice AndyBeauty is in the eyes of the beerholder |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-04-06 : 02:54:53
|
| That sholud beif cdbl(price1)> 100000 and cdbl(price1) < 20000 newprice=10000MadhivananFailing to plan is Planning to fail |
 |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2005-04-06 : 03:15:11
|
| I need the loopI am doingif @mypercent>.95beginwhile @mypercent>.95Beginif @price1>2000000 select @newprice=1100000if @price1> 100000 and @price1< 20000 select @newprice=10000 @mypercent=@newprice/@price2endendI am getting an errorIncorrect syntax near the keyword 'end'.why? Can i do a loop within the if statement |
 |
|
|
AndyB13
Aged Yak Warrior
583 Posts |
Posted - 2005-04-06 : 03:58:21
|
if @mypercent>.95beginwhile @mypercent>.95Beginif @price1>2000000 select @newprice=1100000if @price1> 100000 and @price1< 20000 select @newprice=10000 set @mypercent=@newprice/@price2endendBeauty is in the eyes of the beerholder |
 |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2005-04-06 : 04:01:27
|
| Still the same error -- any other ideas? |
 |
|
|
AndyB13
Aged Yak Warrior
583 Posts |
Posted - 2005-04-06 : 04:18:05
|
Post your full codeBeauty is in the eyes of the beerholder |
 |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2005-04-06 : 05:24:51
|
| Thanks for your help -- i found the error |
 |
|
|
kimberr
Starting Member
9 Posts |
Posted - 2005-04-06 : 06:54:22
|
| What was the error? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-04-06 : 07:02:23
|
| Try thisif @mypercent>.95while @mypercent>.95Beginif @price1>2000000 select @newprice=1100000if @price1> 100000 and @price1< 20000 select @newprice=10000 @mypercent=@newprice/@price2endMadhivananFailing to plan is Planning to fail |
 |
|
|
|