Home » Developer & Programmer » Forms » problem in retrievin the value from database to a form
problem in retrievin the value from database to a form [message #305847] Wed, 12 March 2008 03:37 Go to next message
sharathmpatil
Messages: 38
Registered: February 2008
Location: Bangalore
Member
Hi,
There is block called inv13 where the box details are stored. now i am doin and edit/view form. the relation between inv and inv13 is that the sl_no of inv is stored in inv13. So when the user clicks the edit/view button
it must retrieve the data from data base n jus display the valuesin in the inv13 block.
below the code is written. please look into it n let me know how i can do it.

FUNCTION GET_INV13 (msl number) return number is
cursor inv13(invsl in number) is select * from inv13
where inv13.inv_sl = invsl;
BEGIN
go_block('inv13');
first_record;
for i in inv13(msl) loop

if :inv13.sl_no is not null then
select box_no,box_desc,box_qty,box_weight into :inv13.box_no,:inv13.box_desc,
:inv13.box_qty,:inv13.box_weight from inv13
where inv_sl= :inv13.inv_sl ;
end if;
exit when :system.last_record = 'TRUE';
next_record;
end loop;
return 1;
exception
when others then
g.dummy := g.cent('came to get_inv13 exception',1,1);
return 0;
END;

Table structure of inv13.

CO_CODE, SL_NO, INV_SL, DOC_NO, TYPE_SL, PR_TYPE, YEAR, LOGIN, ENTRY_DATE, BOX_NO, BOX_DESC, BOX_QTY, BOX_WEIGHT

Thanks in advance

Re: problem in retrievin the value from database to a form [message #305954 is a reply to message #305847] Wed, 12 March 2008 07:17 Go to previous message
Flash
Messages: 34
Registered: February 2008
Member
Hi Sharath,

Bugs in your code,
1. Dont need to select items already selected. Use the same for display. You've selected twice.

2. FOR Loop doesnt need an exit.


Code is pretty simple - Based on scott.emp
-------------------------------------------
DECLARE

CURSOR c_get_emp ( P_dept in number ) is select * from emp where deptno = P_dept ;

BEGIN

first_record;

for i in c_get_emp(:dept) loop

if i.empno is not null then
:empno := i.empno;
:ename := i.ename;
end if;

next_record;

end loop;

first_record;

EXCEPTION
WHEN OTHERS THEN
NULL;
END;

See Attached file

Thanks
Flash

[Updated on: Wed, 12 March 2008 07:19]

Report message to a moderator

Previous Topic: SHORT CUT RUN DONT DISPLAY ITEM
Next Topic: please explain this procedure
Goto Forum:
  


Current Time: Sun Feb 09 04:34:27 CST 2025