Enjoying Database Administration

21.1.09

Things you can't do... but ought to be able to

Today I came across a scenario in which I wanted to concatenate selected fields into a great big super field. The reason for this is that I am in the process of creating a series of extracts to conform to a fixed length format specified by an industry standards body. In short I wish SQL (DB2) specifically, had the ability to accept syntax like:

SELECT CONCATENATE ALL FROM [SUBBSELECT TABLE] WITH [PADDING DELIMITER '']

Wouldn't it be just great to concatenate all from a sub-select or table with padding or a named delimiter? Sure if you wanted to get into the nitty gritty WITH PADDING would need a list along with it like:

SELECT CONCATENATE ALL FROM cte_NamedCTE WITH PADDING (col1 LEFT '0', col2 RIGHT '#', col3 RIGHT '-', col4 LEFT 'X')

I sure think it would be boffo and uber, if that sort of statement were included in the SQL standard, or the SQL variant of the vendor that pays me for an endorsement.

No comments:

Post a Comment