Using multiple CONCAT( functions

One of the things I do quite often in mySQL is CONCAT( but this is a messy function. That is, unless you think ahead a little.

First present your items to concatenate as items in select:

SELECT
        '-- delete_orphaned_refund_mod_rows.for.'
        ,&txn_response_date
        ,'.to.'
        ,&txn_response_date2
        ,'.on.'
        ,DATE_FORMAT(NOW(),'%Y-%m-%d.%I.%i')
        ,'.sqL'
;
...then format as so:
SELECT
        CONCAT
        (
        CONCAT
        (
        CONCAT
        (
        CONCAT
        (
        CONCAT
        (
        CONCAT
        (
        '-- delete_orphaned_refund_mod_rows.for.'
        ,&txn_response_date
        )
        ,'.to.'
        )
        ,&txn_response_date2
        )
        ,'.on.'
        )
        ,DATE_FORMAT(NOW(),'%Y-%m-%d.%I.%i')
        )
        ,'.sqL'
        )  as "-- delete_orphaned_refund_mod_rows" 
;
...if the SQL client you use (I use WinSQL) does paren matching you can easily see everything is matched -- but, visually, it's relatively clear as well.

-Cheers

No comments:

Favorite Tweets