![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I've learned to live with the cryptic but powerful syntax of the DB2 LOAD command, but I wish there was a way to sprinkle comments inside it, like so: LOAD CLIENT FROM /path/to/file OF ASC MODIFIED BY BINARYNUMERICS PACKEDDECIMAL USEDEFAULTS CODEPAGE=37 RECLEN=2920 METHOD L ( 01 04, -- col01: id 05 10, -- col02: desc 11 11, -- col03: status_ind 12 21, -- col04: status_short_txt 22 40, -- col05: status_long_txt ...) Any clever ideas/hacks out there, outside of a pre-processor to remove the comments before sending them to DB2? |
#3
| |||
| |||
|
|
On 2011-02-24, Doug B <bla... (AT) gmail (DOT) com> wrote: I've learned to live with the cryptic but powerful syntax of the DB2 LOAD command, but I wish there was a way to sprinkle comments inside it, like so: LOAD CLIENT FROM /path/to/file OF ASC MODIFIED BY BINARYNUMERICS PACKEDDECIMAL USEDEFAULTS CODEPAGE=37 RECLEN=2920 METHOD L ( * 01 04, -- col01: id * 05 10, -- col02: desc * 11 11, -- col03: status_ind * 12 21, -- col04: status_short_txt * 22 40, -- col05: status_long_txt ...) Any clever ideas/hacks out there, outside of a pre-processor to remove the comments before sending them to DB2? First of all I recommend the NONRECOVERABLE and REPLACE options for all loads to keep from filling up log files. Second I recommend ending all DB2 sessions with a TERMINATE command to keep from tying up the database. To get to your question one can use standard unix command line utilities. Here is a unix session using the cat and sed commands: $ cat old.sql LOAD CLIENT FROM /path/to/file OF ASC MODIFIED BY BINARYNUMERICS PACKEDDECIMAL USEDEFAULTS CODEPAGE=37 RECLEN=2920 METHOD L ( * 01 04, -- col01: id * 05 10, -- col02: desc * 11 11, -- col03: status_ind * 12 21, -- col04: status_short_txt * 22 40, -- col05: status_long_txt ...) $ cat old.sql | sed -e 's/--.*//' LOAD CLIENT FROM /path/to/file OF ASC MODIFIED BY BINARYNUMERICS PACKEDDECIMAL USEDEFAULTS CODEPAGE=37 RECLEN=2920 METHOD L ( * 01 04, * 05 10, * 11 11, * 12 21, * 22 40, ...) $ cat old.sql | sed -e 's/--.*//' > new.sql $ cat new.sql LOAD CLIENT FROM /path/to/file OF ASC MODIFIED BY BINARYNUMERICS PACKEDDECIMAL USEDEFAULTS CODEPAGE=37 RECLEN=2920 METHOD L ( * 01 04, * 05 10, * 11 11, * 12 21, * 22 40, ...) comet.berkeley aT gmail D0t com -- --------------------------------------------------------------------- Don't knock President Fillmore. *He kept us out of Vietnam.- Hide quoted text - - Show quoted text - |
#4
| |||
| |||
|
|
First of all I recommend the NONRECOVERABLE and REPLACE options for all loads to keep from filling up log files. |
#5
| |||
| |||
|
|
Any clever ideas/hacks out there, outside of a pre-processor to remove the comments before sending them to DB2? |
![]() |
| Thread Tools | |
| Display Modes | |
| |