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!

Generate Fixed length file from ATP

Priya Jayaraman-OracleMay 3 2023 — edited May 3 2023

Hi,

There is a requirement to create fixed length file from data in ATP tables

Say there are 100 records in a table, i have to create a file with length of 1200 for each line

So, in my PLSQL block, I have created a cursor to fetch all records based on the primary key and below is the piece of code

  FOR rec\_data\_import\_hdr IN cur\_category\_hdr           
    LOOP  
          lb\_detail\_transactions := concat(lb\_detail\_transactions,'731'||**rpad('test',1197)**||chr(13));  
    END LOOP;  
  lb\_contents\_final := clob\_to\_blob\_fn(lb\_detail\_transactions);          
  dbms\_cloud.put\_object(credential\_name => l\_credential, object\_uri => l\_fbdi\_obj\_fileref||l\_out\_file\_name,   
               contents => lb\_contents\_final);

Here, expectation is, say if there are 50 records in the table, I will have 50 lines with total length of 1200 and chr13 for eahc line

But, RPAD function doesn't work properly in all iterations. While i see the file, few lines are having less chars as 1197 only instead of 1200

I am getting the below result.

Could you please help us here?

Thanks,

Priya

Comments
Post Details
Added on May 3 2023
2 comments
167 views