• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3164
  • Last Modified:

Loop through oracle form fields


Dear Expert,


Iam working on oracle 6i.

Iam developing a form.

It has a block route_detail.and it has max 10 rows.

The block name is route_detail and it has

route_id  route_name
1          name1
2          name2
3          name3
and so on till 10 records.

I have a requirement .

There is a button in the block.

If i press the button .it has to loop through the block

and get the value of the route_id field and store the values in a temp variable

like l_temp := (1,2,3,...);

Please help me.

Thanks
0
daprjo
Asked:
daprjo
1 Solution
 
Muhammad Ahmad ImranDatabase DeveloperCommented:
can you post some more table description and post your .fmb file
0
 
emaas_usCommented:
DECLARE
  v_variable (VARCHAR2)1000);
BEGIN
  GO_BLOCK('NAME OF BLOCK');
  FIRST_RECORD;
  FOR i IN 1..10 LOOP
    v_variable := v_variable || :BLOCK_NAME.FIELD_NAME || ',';
    NEXT_RECORD;
  END LOOP;
  FIRST_RECORD;
  v_variable := RTRIM(v_variable,','); --strip off trailing commas
END;
 
0
 
kumar_manimaranCommented:
Try the below code:

Declare

blk_id block;
frec number:=:SYSTEM.cursor_record;
lrec number:=:SYSTEM.cursor_record;
l_temp Varchar2(3000) :='';

Begin

blk_id := find_block('route_detail');

go_block('route_detail ');

    FIRST_RECORD;
    frec := get_block_property(blk_id,CURRENT_RECORD);    -- Get first record
    LAST_RECORD;
    lrec := get_block_property(blk_id,CURRENT_RECORD);    -- Get last record


 For i in frec..lrec loop
 go_record(i);
 
 If l_temp is not null then
 l_temp :=  l_temp||','||route_id;   -- if l_temp variable not empty then add comma
 Else
 l_temp :=  route_id;
 End if;
 End Loop;

 l_temp :='('||l_temp||')';   -- adding parenthesis , if you need it
 
     Exception
     When Others then
     Message('Error occured '||sqlerrm);
 End;
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now