Search code examples
oracle-databaseplsqloracle-apex

APEX Oracle filling the item with line values


I have an item of text type P_10_TEXTITEM. I would like to populate this item with values via SQL code, where each value would be on a new row. When I populate this item, nothing appears....

I have an item of text type and I would like to assign to it the line values via SQL code

    for row in (select EName, Comm from EMP
                 where instr( ':'||:P18_SHARED_SALESMAN||':',  ':'||EmpNo||':' ) > 0 )
    loop
          :P18_SHARED_NEW_COMMISSIONS := :P18_SHARED_NEW_COMMISSIONS || row.EName || ': ' || row.Comm || chr(13) || chr(10); 
     end loop;
    -- Step 5: Write the item values.
    :P18_SHARED_SALE_COMMISSION  := v_saleCommission;
    :P18_SHARED_COMMISSION_EACH  := v_commissionEach;

the variables are already displayed, but they do not line up enter image description here


Solution

  • You didn't say how exactly you're doing that; what is row? How are local variables declared?

    Anyway: using Scott's sample schema, my FOR cursor loop populates Textarea item with employees and their jobs. To do that, I created a Page Load dynamic action:

    begin
      :P2_TEXT := null;
      
      for cur_r in (select ename, job from emp where deptno = 20) loop
        :P2_TEXT := :P2_TEXT || cur_r.ename ||', '|| cur_r.job || chr(13);
      end loop;
    end;
    

    Have a look at screenshot which shows both dynamic action and output:

    enter image description here