Domanda

I have the following code, it loops over an oracle forms block and then compares it with data from a cursor (the cursor takes data from the block itself). due to the three loops the performance is pretty bad and grows exponentially with lots of records. Any advice on how to improve it?

loop
    if :PAYMENTS_COLLECTIONS.CHECK_BOX='Y' then
        temp_rec := :system.cursor_record;
        acc_payment_no1 := :payments_collections.acc_payment_numb;

        for pay_same_trans in payments_in_same_trans(:payments_collections.acc_payment_numb) 
        loop
            first_record;
            acc_payment_no2 := pay_same_trans.acc_payment_no;

            REMOVE_PAID_TRANSACTION(pay_same_trans.payment_trans_seq_no);
            loop
                if pay_same_trans.acc_payment_no = :PAYMENTS_COLLECTIONS.acc_payment_numb and :PAYMENTS_COLLECTIONS.CHECK_BOX='Y' then
                    receipt_selected := true;
                    exit;
                end if;
                if :system.last_record = 'TRUE' then
                  exit;
                end if; 
                next_record;
            end loop;
            if receipt_selected = false then
                raise not_reverting_whole_trans;
            end if;
            receipt_selected := false;
        end loop;
        go_record(temp_rec);
    end if;
    if :system.last_record = 'TRUE' then
      exit;
    end if; 
    next_record;
end loop;
È stato utile?

Soluzione

You could post all block data to the db in a temp table, then run a procedure to check the data with joins, which will be orders of magnitude more efficient than your logic.

Then insert/delete/update in the final tables as per your business requirement, then re-query the block from db.

You'll have to rewrite pretty much all your logic but you'll have created a nice interface in PL/SQL that you will be able to reuse the day you drop Forms for something else.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top