Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to use rpad , lpad or substr function in the out put files in oracle plsql?

Rajesh123Apr 22 2015 — edited Apr 27 2015

Hi all,

Declare

   v_account varchar2(30) := '01-000-000-0000-000-0000 ';

   v_WIP varchar2(30) := '123435';

   v_code varchar2(30) := 'PURCHASE_PRICE_VARIANCE';

   v_dr number:=248.8;

   v_cr number:=248.8;

Begin

dbms_output.put_line('        Account Segments          '||'   '||' WIP Entity Name      '||'   '||'       Accounting class code          '||'  '||' Accounted DR '||'  '||' Accounted CR ');

dbms_output.put_line('----------------------------------'||'   '||'----------------------'||'   '||'--------------------------------------'||'  '||'-------------------'||'  '||'------------------- ');

dbms_output.put_line(rpad(v_account,30)||rpad(v_WIP,25)||rpad( v_code,34)||' '||rpad(v_dr,20)||rpad(v_cr,20));

End;

Getting out put as

       Account Segments                  WIP Entity Name             Accounting class code               Accounted DR          Accounted CR

----------------------------------   ----------------------   --------------------------------------  -------------------  -------------------

01-000-000-0000-000-0000                  123435                   PURCHASE_PRICE_VARIANCE               248.8                    248.8              

But if i have v_code value is 'ABCDGE' then

        Account Segments                  WIP Entity Name             Accounting class code                 Accounted DR      Accounted CR

----------------------------------   ----------------------   --------------------------------------  -------------------  -------------------

01-000-000-0000-000-0000                     123435            ABCDGE                             248.8               248.8              

can you please help me how to resolve these type of issues?

Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production

thanks

This post has been answered by aJohny on Apr 27 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 25 2015
Added on Apr 22 2015
52 comments
14,267 views