I ran across a problem with the format of an ASCI output file of an SQL script. The problem I have is with handling a particular column that contains account numbers. The column is defined with 8 characters. However not every entry has data. I have several fields that don't have any information.
Originally in my script I had the following line that made the script fail:
I then changed the line to the following: (The script ran but now I notice that the formatting is wrong)
I attempted to use the NVL function that will return a value when there is nothing in the column field but it doesn't work. Does anyone know what I'm doing wrong?
You're right JMartinez, if the field is either NULL or 8 characters long, then LPAD is not needed. Otherwise, if 8 is just a max size and there are shorter values, but you want the output of your query always to be 8 characters long, left-padded with zeros, then LPAD is needed.