Home » Developer & Programmer » Forms » HOW TO UPDATE CURRENT ROW Comparing it with Existing Value..
HOW TO UPDATE CURRENT ROW Comparing it with Existing Value.. [message #590094] Sun, 14 July 2013 21:13 Go to next message
D_ORA
Messages: 32
Registered: November 2012
Location: UK
Member
I have master-detail form I would like to update the emp1 table on the base of current value of dept table deptno and emp table ename .

update emp1
set ename = :emp.ename
where ename =
(select ename from emp e
where e.ename=:emp.ename
and e.deptno=:dept.deptno);

I try the above query but it did not able to update emp1 table.
Any advice will be appreciated...

[Updated on: Sun, 14 July 2013 21:15]

Report message to a moderator

Re: HOW TO UPDATE CURRENT ROW Comparing it with Existing Value.. [message #590095 is a reply to message #590094] Sun, 14 July 2013 21:18 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/
Re: HOW TO UPDATE CURRENT ROW Comparing it with Existing Value.. [message #590097 is a reply to message #590095] Sun, 14 July 2013 21:47 Go to previous messageGo to next message
D_ORA
Messages: 32
Registered: November 2012
Location: UK
Member
Can you please let me know how to attaché more then one file...I tried to send the files which consist on four screen shots ...but on this topic it allowing only on files per message...
Re: HOW TO UPDATE CURRENT ROW Comparing it with Existing Value.. [message #590098 is a reply to message #590095] Sun, 14 July 2013 21:51 Go to previous messageGo to next message
D_ORA
Messages: 32
Registered: November 2012
Location: UK
Member
UPDATE emp1
SET ename = :emp.ename
WHERE ename = (SELECT ename
FROM emp e

WHERE e.ename = :emp.ename
AND e.deptno = :dept.deptno);
Re: HOW TO UPDATE CURRENT ROW Comparing it with Existing Value.. [message #590099 is a reply to message #590098] Sun, 14 July 2013 22:03 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>I tried to send the files which consist on four screen shots
what does Posting Guidelines say about attached files & screen shots?

for plain SQL what are ":emp.ename" & ":dept.deptno" and where do they originate
Re: HOW TO UPDATE CURRENT ROW Comparing it with Existing Value.. [message #590101 is a reply to message #590099] Sun, 14 July 2013 22:22 Go to previous messageGo to next message
D_ORA
Messages: 32
Registered: November 2012
Location: UK
Member
Hi this is the code on WHEN-BUTTON-PRESSED on the MAster-Detail Form .
which Is taking the Deptno , ename from the form
Re: HOW TO UPDATE CURRENT ROW Comparing it with Existing Value.. [message #590103 is a reply to message #590099] Sun, 14 July 2013 22:59 Go to previous messageGo to next message
D_ORA
Messages: 32
Registered: November 2012
Location: UK
Member
Please see the following screen .../forum/fa/10985/0/

The next screen I m sending in next message...Thanks for your passion.
  • Attachment: Scr1.jpg
    (Size: 61.65KB, Downloaded 1264 times)
Re: HOW TO UPDATE CURRENT ROW Comparing it with Existing Value.. [message #590105 is a reply to message #590103] Sun, 14 July 2013 23:03 Go to previous messageGo to next message
D_ORA
Messages: 32
Registered: November 2012
Location: UK
Member
ON THE WHEN-BUTTON-PRESSED I PUT THE FOLLOWING CODE..

/forum/fa/10986/0/
  • Attachment: scr2_1.jpg
    (Size: 18.96KB, Downloaded 1238 times)

[Updated on: Sun, 14 July 2013 23:03]

Report message to a moderator

Re: HOW TO UPDATE CURRENT ROW Comparing it with Existing Value.. [message #590106 is a reply to message #590099] Sun, 14 July 2013 23:06 Go to previous messageGo to next message
D_ORA
Messages: 32
Registered: November 2012
Location: UK
Member
I am hopping it is enough information to get into this issue..
/forum/fa/10987/0/


The result suppose to be come "test" instead of "King" in emp1....Any advice will be appreciated..
  • Attachment: scr2.jpg
    (Size: 13.14KB, Downloaded 1235 times)

[Updated on: Sun, 14 July 2013 23:08]

Report message to a moderator

Re: HOW TO UPDATE CURRENT ROW Comparing it with Existing Value.. [message #590115 is a reply to message #590106] Mon, 15 July 2013 00:15 Go to previous messageGo to next message
Littlefoot
Messages: 21811
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
There are two data blocks in your form. What tables are they based on? I suppose DEPT and EMP (while you'd want to update EMP1 table which is ... what? Copy of EMP?).

If that's so, then your UPDATE statement says the following: set EMP1.ENAME to a value that is contained in EMP.ENAME form item that belongs to a current record (that would be 'test') WHERE ENAME equals ENAME from EMP table where ENAME = :EMP.ENAME (which is 'test' again) and DEPTNO = :DEPT.DEPTNO (which is 30). As there's no employee in EMP table whose name is 'test', no records are updated.

However, that might be completely wrong. Provide some more information (especially answer a question I asked in the first paragraph). Also, let us know how these tables look like (EMP1) and values stored within.
Re: HOW TO UPDATE CURRENT ROW Comparing it with Existing Value.. [message #590159 is a reply to message #590115] Mon, 15 July 2013 08:12 Go to previous messageGo to next message
D_ORA
Messages: 32
Registered: November 2012
Location: UK
Member
Littlefoot thanks for your reply ..I would like to update the emp1 table on the base of current value of the deptno from dept table and ename from the emp table ..Is there any possibility to set update emp1 set=:ename (where :ename in the emp table already entered previously not at that part of time ,I consider :ename here as the cursor item).
In short I like to update emp1 ename on the base of emp table ename and dept deptno which already exist on these table..
Re: HOW TO UPDATE CURRENT ROW Comparing it with Existing Value.. [message #590192 is a reply to message #590159] Mon, 15 July 2013 14:41 Go to previous messageGo to next message
Littlefoot
Messages: 21811
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If you are sure that UPDATE statement you wrote does the job correctly (because you tested it in SQL*Plus, providing actual values for form items), then I have only one question: did you - in a form - commit changes you've made? I believe that an ordinary COMMIT won't do the job because it would update changes in these data blocks. For UPDATE statement, you'd have to put
standard.commit;
at the end of the WHEN-BUTTON-PRESSED trigger.
Re: HOW TO UPDATE CURRENT ROW Comparing it with Existing Value.. [message #590212 is a reply to message #590192] Mon, 15 July 2013 18:24 Go to previous message
D_ORA
Messages: 32
Registered: November 2012
Location: UK
Member
I have tried that as well ...as you know I am just trying to update the value on the base of emp-> ename and dept-> deptno
Previous Topic: updating records values and post trigger causing issues
Next Topic: Delete Or Over write .FMX on AS
Goto Forum:
  


Current Time: Sat Jun 29 06:27:51 CDT 2024