Skip to Main Content

APEX

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 can I export numeric values (stored in VARCHAR fields) to CSV with leading zeros?

ToolTimeTaborApr 6 2018 — edited Apr 6 2018

Problem:  How do I get the Interactive Grid to export essential numeric values in a VARCHAR2 field to a CSV as text?

Background: We have a table that has an ORG_CODE field that is VARCHAR2(3) that contains essentially numeric data.  When we export it using the Interactive Grid, Action, Download, CSV feature it drops the leading zeros (or Excel ignores them) when opened in Excel.

I suspect the latter, that Excel "sees" numeric values and treats the column as numeric data.  The problem is, the ORG_CODE could contain text, but our users chose "numeric" codes rather than "alpha" codes for their organizations.  So, instead of "HQ" the use "001" in the VARCHAR2 field.  In the database, the leading zeroes are retained, as it treats the "001" as text.

When the values are downloaded to the CSV, Excel opens the column and displays "1" rather than "001" in the column.  Our users want the leading zeros in the CSV.  Is there a way to export the full three characters and get Excel to treat the field as text?

Rob

Thanks Mint,  you were spot on.  The raw data (viewed in notepad) has the leading zeroes.

This post has been answered by Mint-Innit on Apr 6 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 4 2018
Added on Apr 6 2018
2 comments
1,053 views