pl/sql fixed file creation

5 pts.
Tags:
PL/SQL
SQL
I am new to the pl/sql world. I'm ok with writing out a comma delimited file but I can't figure out how to write out a file where the fields are fixed length. I could use some examples. thanks,

Software/Hardware used:
windows

Answer Wiki

Thanks. We'll let you know when a new response is added.

My PL/SQL is a bit rusty, but …

To generate a field of a fixed length, the easiest way is to first PAD the field on the right with blanks, then take the LEFT side of that padded string in the length you want.

For example to get a field of exactly length 50, you could use:

<pre>sOutField = LEFT( RPAD ( sInField, 50 ), 50 );</pre>

This will add 50 blanks to the right side of the input field value, then take the leftmost resulting 50 characters as the result field.

Simply concatenate the individual fields together to get the fixed-length output line.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following