Update from forms [message #384729] |
Thu, 05 February 2009 00:11 |
anugraha
Messages: 15 Registered: February 2009
|
Junior Member |
|
|
Hi !
I have a block in my form based on ch_pwd
Table name:ch_pwd block:ch_pwd
employeeid,old_password,new_password,confirm_new_password
Table name:emp_login
employeeid,password
In block ch_pwd, i have placed 2 buttons, one for save and other for update..
After the clicking save, i would click update to update the records saved in this table to another table(emp_login)..
I used the coding
Table Name:ch_pwd,emp_login
UPDATE emp_login A
SET password = (SELECT new_password FROM ch_pwd WHERE EMPLOYEEID = A.EMPLOYEEID);
and also tried with
UPDATE emp_login
SET password = ( SELECT password
FROM ch_pwd
WHERE emp_login.employeeid = ch_pwd.employeeid)
WHERE EXISTS
( SELECT password
FROM ch_pwd
WHERE emp_login.employeeid = ch_pwd.employeeid);
Both didnt work .. the data is not getting updated..
Pls help to overcome this..
Thanks and Regards
anu
|
|
|
Re: Update from forms [message #384777 is a reply to message #384729] |
Thu, 05 February 2009 02:58 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
You "forgot" to join table columns with forms data block columns; something likeUPDATE emp_login A SET
password = (SELECT new_password FROM ch_pwd WHERE EMPLOYEEID = :your_data_block.EMPLOYEEID)
where employeeid = :your_data_block.employeeid;
However, you might probably do that as
update emp_login set
password = :your_data_block.new_password
where employeeid = :your_data_block.employeeid;
[Updated on: Thu, 05 February 2009 02:59] Report message to a moderator
|
|
|
|
|
Re: Update from forms [message #384955 is a reply to message #384926] |
Thu, 05 February 2009 22:00 |
anugraha
Messages: 15 Registered: February 2009
|
Junior Member |
|
|
yes sir i did..
If give commit its updating all the rows of the table instead of updating a single row corresponding to the employeeid..
Thanks and Regards
anu
|
|
|
Re: Update from forms [message #384956 is a reply to message #384955] |
Thu, 05 February 2009 22:39 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
All the records? In that case, I'm afraid that you didn't look carefully enough into my example - your UPDATE misses the WHERE condition which tell Oracle to update exactly one record - the one that belongs to that particular employee:UPDATE ...
SET ...
where employeeid = :your_data_block.employeeid; --> you are missing this line
By the way, saying that "it does not work" isn't very descriptive. Why didn't you post your current UPDATE statement? Without it, all we can do is guess.
|
|
|