Alex
Alex

Reputation: 11

Oracle forms 10g

I'm new to oracle forms and i have a problem. I have two multiple records blocks with same fields in the form.

I query data for one block, it gets populated .

Is where a way to copy all rows from populated block to 'copy' block?

Upvotes: 0

Views: 235

Answers (1)

Littlefoot
Littlefoot

Reputation: 143083

Yes, there is a way. One is to manually type those values over there, but that's probably not what you want.

Another is to create a button (let's call it BTN_COPY) and create WHEN-BUTTON-PRESSED trigger on it. It'll look like code that follows (based on items that belong to Scott's EMP table); note that I can't test it, but - I hope it'll be OK.

declare
  -- local variables; should contain all items you'd want to copy
  l_empno  emp.empno%type;
  l_ename  emp.ename%type;
  l_job    emp.job%type;
  -- l_currec will contain current row number in the first block
  l_currec number := 0;
  -- l_exit will be used if we're at the end of the first block
  l_exit varchar2(1) := 'N';
begin
  loop
    -- go to the source (first block) and the [last row you were in + 1]
    go_block('first');
    l_currec := l_currec + 1;
    go_record(l_currec);

    -- check whether this is the last row of the first block; if so, exit the loop
    if :system.last_record = 'TRUE' then
       l_exit := 'Y';
    end if;

    -- save current row's items
    l_empno := :first.empno;
    l_ename := :first.ename;
    l_job   := :first.job

    -- go to the second block's bottom and create a new record
    go_block('second');
    last_record;
    create_record;

    -- put stored values into the second block's items
    :second.empno := l_empno;
    :second.ename := l_ename;
    :second.job   := l_job;

    -- exit the loop if this was the last record to be copied
    exit when l_exit = 'Y';
  end loop;
end;

Upvotes: 1

Related Questions