Search code examples
sqldatabasedb2zos

pad smallint with 0s in DB2 sql for z/os


is there any way to pad 0's to smallint in DB2 for mainframe z/OS. I am not writing any program but running query directly on DB2 QMF.

Field definition:

Column Name  Col type length
some_column  Smallint  2

 some_column     result
 -----------     ------
  288         ==>  0288
  88          ==>  0088
  1224        ==>  1224

Solution

  • In all currently supported versions of DB2 for z/OS there's a function DIGITS() that does exactly what you need.