“It works, just not for the reason you think”

A somewhat mistaken attempt to format a number left-padded with up to six zeroes, made me cringe a little:

SELECT LPAD(number_column, 6, 000000) FROM ...

Yes, it does work (the domain of number_column is limited to positive integers), but not for the reason the writer thought, I think.

(Hint: what is the data type of the third parameter to LPAD?)

Count All Rows in a Schema
AUSOUG Perth 2010 – Day 1

Leave a Reply

Your email address will not be published / Required fields are marked *