Getting data to unload
I have a DB2 column defined as varchar(300) that is used to store dates in packed decimal form. The date is stored as an array of 5 bytes each.

If there are 10 dates, then the length of the column is 50 bytes. When I try to unload this column using DSNTIAUL, the first 50 bytes are unloaded as is but the rest of the 250 bytes is padded with low-zeroes (x'00').

Is there any option to change the pad character to spaces when unloading the data?

    Requires Free Membership to View

    When you register, you'll begin receiving targeted emails from my team of award-winning writers. Our goal is to keep you informed on the hottest data and information management trends today.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchDataManagement.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchDataManagement.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

Since you are using DSNTIAUL, you cannot use the VARCHAR STRIP TRAILING specification that can be set using the UNLOAD utility. However, you should be able to use DSNTIAUL to unload data from a view. To solve your particular problem, create a view of the table that selects all of the columns, except for the VARCHAR(300) column. Instead, use the STRIP function on that column.

For example, if the VARCHAR(300) column is named VCOL, specify it as follows in the SELECT of the view:

STRIP(VCOL,TRAILING)

This will cause trailing blanks to be stripped off. Then, use DSNTIAUL to unload from the view instead of the table, and that should do the trick.

Good luck!

Editor's note: Do you agree with this expert's response? If you have more to share, post it in one of our .VO7aaqqaAFk.0@/search390>discussion forums.

This was first published in October 2004