| Author |
Topic |
|
chandusama
Starting Member
13 Posts |
Posted - 2008-04-06 : 17:33:11
|
| hi guyz,i am having a doubt.The problem i am facing is tht i have a table in which one column is a condition column and other column is action column. Now how can i give a condition such that if the condition is true the action must be fired. This is like a if statement ...where if the condition is true the corresponding action in the table has to be firedCan someone help me with thisSama |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-04-06 : 17:57:44
|
| Do you have sample data and the result like to get? |
 |
|
|
chandusama
Starting Member
13 Posts |
Posted - 2008-04-06 : 18:05:26
|
| this is the table..condition------------------------------------------Action[A]>3 OR ([B]<15 AND [D] > 2)----------------------[E]=3[B] > 3 AND [E] > 16.3 OR [F] < 12-----------------[G]=[B]*[C]([A]+[D])>30 OR [F] > 12---------------------------[H]=14[A] < 10-------------------------------------------[F]=[A]*[D][B] >= 6 ------------------------------------------[D]=B – 3This is the table...now here i have to check each column....lik if i am checking 1st row and there are values assigned to all the variables....so if i am chkin 1st row n its true the action value must be fired....n if it is false it shld check the second row...n so onSama |
 |
|
|
chandusama
Starting Member
13 Posts |
Posted - 2008-04-07 : 00:34:15
|
| can some one help me quickelySama |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-07 : 00:44:19
|
| Use CASE WHEN.. for assigining value to each columnlike [E]=CASE WHEN [A]>3 OR ([B]<15 AND [D] > 2) THEN 3 END,[G]= CASE WHEN [B] > 3 AND [E] > 16.3 OR [F] < 12 THEN [B] * [C] END,... |
 |
|
|
chandusama
Starting Member
13 Posts |
Posted - 2008-04-07 : 01:31:13
|
| i should not use the condition and action lik that....i am actually writing a stored procedure here where the 1st row in table is taken and the condition is checked ..if its true then the action must be firedSama |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-07 : 01:44:26
|
quote: Originally posted by chandusama i should not use the condition and action lik that....i am actually writing a stored procedure here where the 1st row in table is taken and the condition is checked ..if its true then the action must be firedSama
you can use case constructs within select/update statements. If you need more help, can you post what exactly you're trying to do? |
 |
|
|
chandusama
Starting Member
13 Posts |
Posted - 2008-04-07 : 02:16:14
|
| ok here is wat i exactly needhere is 1st table AttributesA 1B 6C 3.5and my second table rules1 [A]>3 OR ([B]<15 AND [D] > 2)-------------[E]=32 [B] > 3 AND [E] > 16.3 OR [F] < 12--------[G]=[B]*[C]3 ([A]+[D])>30 OR [F] > 12------------------[H]=144 [A] < 10----------------------------------[F]=[A]*[D]5 [B] >= 6----------------------------------[D]=B – 3i hav to write a stored procedure where in the rules table the 1st condition shld be checked ..corresponding to their values in the attributes table. for ex...in the ist condition since D is not yet known it skips the first row n goes to next rowin the 2nd row snice E and F are not known it skips this condition and so on lik tht it comes to last condition where condition will be true and by that the action can be enabled where D value can be known. After this it goes to first row condition and calculates all the values like that..On the way while v know all the attributes v must replace the attributes in table with their values.....like the first row shld be 1<3 or (3.5 < 15 and Dvalue >2)...and so onnSama |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-07 : 02:32:52
|
| So what will be your table structures? Two tables with two columns? |
 |
|
|
chandusama
Starting Member
13 Posts |
Posted - 2008-04-07 : 02:40:08
|
| yes two tables with two structures1st table structure isAttribute---varchar(40)value ----realand the second table is condition----varcharaction ----varcharSama |
 |
|
|
chandusama
Starting Member
13 Posts |
Posted - 2008-04-07 : 21:41:18
|
| ANYONE WHO CAN HELPSama |
 |
|
|
|