| Author |
Topic |
|
Tamer
Starting Member
22 Posts |
Posted - 2008-08-20 : 06:25:58
|
| Dear Experts,what is the problem with this statment**********insert into employee1(e_no,e_name1)select employee.e_no,employee.e_name1 when employee.e_no=1 then 1000when employee.e_no=2 then 2500else employee.e_no endfrom employee**********I got this in the message tabIncorrect syntax near the keyword 'when'.Thanks in Advance |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-20 : 06:29:40
|
| insert into employee1(e_no,e_name1,othercol)select employee.e_no,employee.e_name1 case when employee.e_no=1 then 1000when employee.e_no=2 then 2500else employee.e_no endfrom employeeMadhivananFailing to plan is Planning to fail |
 |
|
|
Tamer
Starting Member
22 Posts |
Posted - 2008-08-20 : 06:55:31
|
| According to your statmentI get this message in the message tabIncorrect syntax near the keyword 'case' |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-20 : 07:02:25
|
quote: Originally posted by madhivanan insert into employee1(e_no,e_name1,othercol)select employee.e_no,employee.e_name1, case when employee.e_no=1 then 1000when employee.e_no=2 then 2500else employee.e_no endfrom employeeMadhivananFailing to plan is Planning to fail
missed a comma |
 |
|
|
Tamer
Starting Member
22 Posts |
Posted - 2008-08-20 : 07:07:42
|
| I am so sorry , but I get this in the message tabThe select list for the INSERT statement contains more items than the insert list. The number of SELECT values must match the number of INSERT columns. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-20 : 07:12:51
|
quote: Originally posted by Tamer I am so sorry , but I get this in the message tabThe select list for the INSERT statement contains more items than the insert list. The number of SELECT values must match the number of INSERT columns.
You should specify the third column See my queryMadhivananFailing to plan is Planning to fail |
 |
|
|
Tamer
Starting Member
22 Posts |
Posted - 2008-08-20 : 08:44:43
|
| Thank you Mr.but this retrieve the data without changing it according to the criteria in the case...endit bring the data as it is in the original tableTamer |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-20 : 09:18:38
|
quote: Originally posted by Tamer Thank you Mr.but this retrieve the data without changing it according to the criteria in the case...endit bring the data as it is in the original tableTamer
why? waht was your e_no value? and what value you got for third column? |
 |
|
|
Tamer
Starting Member
22 Posts |
Posted - 2008-08-20 : 09:26:55
|
| Ok Mr.The idea is clear now Thank you very much |
 |
|
|
|