where is the error within this form? [message #328077] |
Wed, 18 June 2008 21:05 |
amdabd
Messages: 91 Registered: November 2007 Location: My Computer
|
Member |
|
|
hi,
my aim is to retrieve data from table EMP into table SAL_3
using cursor within a form.
the form gives error [FRM-40102: Record must be entered or deleted first.]
table SAL_3
------------
EMPNO NUMBER(4),
ENAME VARCHAR2(10),
SAL NUMBER(7,2),
COMM NUMBER(7,2)
thanks
[Updated on: Wed, 18 June 2008 21:09] Report message to a moderator
|
|
|
|
Re: where is the error within this form? [message #328118 is a reply to message #328083] |
Thu, 19 June 2008 00:06 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
There are several problems in the form.
You have never navigated out of the 'block2' block. Trigger you've written deals with 'sal_3' block (at least, that's what you think), but NEXT_RECORD is trying to create a record in the 'block2' block, not in 'sal_3'.
In order to get into the 'sal_3' block, it must have at least one navigable item. So, either make one of these items navigable, or add another one which will suit such a need.
Finally, there's a "better" way to use a cursor - although your way works (incorrectly, though - the last employee is displayed twice; you should think it over), it is better to use a cursor FOR loop as you don't have to declare cursor variable(s), open a cursor, worry when to exit (EXIT should follow FETCH if you want to avoid duplicating the last employee) and close a cursor.
Here's how it might look like:
begin
if :block2.txt_deptno is null then
message('Enter dept number');
else
go_block('sal_3');
for cur_r in (select empno, ename, sal, comm, deptno
from emp
where deptno = :block2.txt_deptno
)
loop
:sal_3.empno := cur_r.empno;
:sal_3.ename := cur_r.ename;
:sal_3.sal := cur_r.sal;
:sal_3.comm := cur_r.comm;
next_record;
end loop;
end if;
end;
|
|
|
|
|
Re: where is the error within this form? [message #328362 is a reply to message #328118] |
Thu, 19 June 2008 20:54 |
amdabd
Messages: 91 Registered: November 2007 Location: My Computer
|
Member |
|
|
hi;
thanks dear Littlefoot
it works properly .
Littlefoot wrote on Thu, 19 June 2008 00:06 | You have never navigated out of the 'block2' block. Trigger you've written deals with 'sal_3' block (at least, that's what you think), but NEXT_RECORD is trying to create a record in the 'block2' block, not in 'sal_3'.
| Actually, Yes this was my error.
thanks everybody
|
|
|