Home » Developer & Programmer » Forms » Inserting Records in Multi Block Form
Inserting Records in Multi Block Form [message #83461] Fri, 10 October 2003 12:49 Go to next message
Derek N
Messages: 80
Registered: September 2002
Member
I Have a form in 6i.

On entering the form I query a database block. After the records display.... I press a button which calls and executes query on another database block which is on a separate smaller window. This block is displayed over the previous block. I scroll thru the records of the second block and select a few records using a check box. I now have to press an insert button which must insert the selected records into the first block. I then navigate to the first block and view the newly inserted records. If I'm happy with the selection.... I commit the records to the database. How can this ne done in forms? Looping through one block and simultaneously inserting records into another block.

Thanks in advance
Re: Inserting Records in Multi Block Form [message #83486 is a reply to message #83461] Thu, 16 October 2003 07:36 Go to previous message
sameer_am2002
Messages: 129
Registered: September 2002
Senior Member
Write this code in the ok button frm where he selects.
declare
type select_rec is record
(
item1 number ,--Should match datatype of item in the block
item2 number ,--Should match datatype of item in the block
item3 number ,--Should match datatype of item in the block
is_checked varchar2(2) --Should match datatype of item in the block
);
/* Create plsql table of above record type*/
type select_tab_var is table of select_rec index by binary_integer ;
/* declare variable of above table */
select_records select_tab_var ;

item_data items_in_block ;--This is built in datatype
lv_cnt number ;
begin
item_data(1) := 'GROUP_1_ID' ;--This should be name of item of which data u need to insert.
item_data(2) := 'USER_1_ID' ;--This should be name of item of which data u need to insert.
item_data(3) := 'SERIAL' ;--This should be name of item of which data u need to insert.
item_data(4) := 'SELECT' ;--This should be name of item of which data u need to insert.
/* Ths is built-in which populate all blocks contents in a plsql table variable*/
TABLE_FROM_BLOCK (select_records ,'USRGRP' , 1 , all_records , item_data ) ;
clear_block(no_validate) ;
go_block('master') ;
lv_cnt := select_records.count ;
/* Now check which of the records were selected and insert them accordingly*/
for x in 1..lv_cnt loop
if select_records(x).is_checked = 1 then
if :system.record_status <> 'NEW' then
create_record ;
end if ;
:master.item1 := select_records(x).item1 ;
:master.item2 := select_records(x).item2 ;
:master.item2 := select_records(x).item2 ;
end if ;
end loop ;
end ;
Previous Topic: Master Detail form 6.0
Next Topic: can anyone answer these que
Goto Forum:
  


Current Time: Sun Aug 14 23:48:26 CDT 2022