Oracle Forms Update Table using Multi-record

2.4k Views Asked by At

I have a multi row block that looks like this in oracle forms:

enter image description here

My query:

Select * from table1;

Looks like this:

+-----+
|value|
+-----+
|    3|
|    3|
|    7|
|    1|
+-----+

The column value is a column in a table to be updated into column new:

enter image description here

So that when I requery, the values on my table should be like this:

+-----+
|value|
+-----+
|    4|
|    6|
|   14|
|    2|
+-----+

I tried on post form commit:

for i in 1 .. :rec_count
loop
    update table1
    set value = :new
    where value = :value;
end loop;

but this only updates the last record that i have.

1

There are 1 best solutions below

0
On BEST ANSWER

It may be proper to use a while loop with first_record and next_record Built-ins from a button by WHEN-BUTTON-PRESSED smart trigger with the following code :

declare
   v_blk varchar2(25) := 'block1';
begin   
   go_block(v_blk);
   first_record;
 while ( :value is not null ) 
 loop
  :value := :value + nvl(:added_value,0);
   next_record;
 end loop;

   commit_form;    

   go_block(v_blk);
   execute_query;
end;