By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,830 Members | 812 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,830 IT Pros & Developers. It's quick & easy.

Remove import file after load

P: n/a
kk
Hello,

I am using the udb 8.1 task scheduler to schedule a load. Is there
any way to also schedule an OS command (win32) to delete the file
after the load? I have a python script that will do what I need, I
just need to call it after the load. One more question: is there
anyway to use the import (rather than the load) to import fixed width
data. It is scheduled every 10 minutes. I would rather insert and
update rather than load. Right now, I have an ugly hack written in
Python that concat's text files(IMS data) and drops them into a load
directory as one file. The DB2 scheduler runs and they are imported.
I just need to delete the file after load so I will not get duplicated
entries in my table. (I do have a primary key but the load seems to
ignore it). any suggestions would be appreciated.

Thank You,

Keith
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Use the exclamation mark in the db2 script file.

select ...
!del someFile

the ! means open an os shell and execute the command.

PM

"kk" <kk********@hotmail.com> a écrit dans le message de
news:44**************************@posting.google.c om...
Hello,

I am using the udb 8.1 task scheduler to schedule a load. Is there
any way to also schedule an OS command (win32) to delete the file
after the load? I have a python script that will do what I need, I
just need to call it after the load. One more question: is there
anyway to use the import (rather than the load) to import fixed width
data. It is scheduled every 10 minutes. I would rather insert and
update rather than load. Right now, I have an ugly hack written in
Python that concat's text files(IMS data) and drops them into a load
directory as one file. The DB2 scheduler runs and they are imported.
I just need to delete the file after load so I will not get duplicated
entries in my table. (I do have a primary key but the load seems to
ignore it). any suggestions would be appreciated.

Thank You,

Keith

Nov 12 '05 #2

P: n/a
The IMPORT command supports the ASC file type which is a fixed length
record. The METHOD options allow you to specify the beginning and ending
column locations in the input file. You can use the INSERT_UPDATE option if
there's a primary key on the table if you want to use SQL to modify the
table.
"kk" <kk********@hotmail.com> wrote in message
news:44**************************@posting.google.c om...
Hello,

I am using the udb 8.1 task scheduler to schedule a load. Is there
any way to also schedule an OS command (win32) to delete the file
after the load? I have a python script that will do what I need, I
just need to call it after the load. One more question: is there
anyway to use the import (rather than the load) to import fixed width
data. It is scheduled every 10 minutes. I would rather insert and
update rather than load. Right now, I have an ugly hack written in
Python that concat's text files(IMS data) and drops them into a load
directory as one file. The DB2 scheduler runs and they are imported.
I just need to delete the file after load so I will not get duplicated
entries in my table. (I do have a primary key but the load seems to
ignore it). any suggestions would be appreciated.

Thank You,

Keith

Nov 12 '05 #3

P: n/a
Ken
kk********@hotmail.com (kk) wrote in message news:<44**************************@posting.google. com>...
One more question: is there anyway to use the import (rather than the load) to import fixed width
Nope, and unfortunately neither import nor load appear to accept
multi-character delimiters.
any suggestions would be appreciated.


Well, the load should enforce your primary key, sounds like something
isn't right there. Imports are nicer for concurrency, but perhaps you
can get the load working better - sending your duplicate data off to
an exceptions table, etc.

You might want to take some precaution prior to loading to ensure that
you don't reload a file - in the event that your delete steps fails.
A check before the load to confirm that no files were left over from
the prior load could help.

Also, would it be simpler to run everything out of python and then
escape out to run the db2 load (using os.system, popen2.Popen3, etc)
than running everything out of db2 scripts and escaping out to run
python?

Lastly, there is a python dbi module for db2, writing a custom import
script might be the ticket.

ken
Nov 12 '05 #4

P: n/a
Ken
ke******@yahoo.com wrote:
No


Shoot, just realized that I was thinking about extracts, not imports
when I wrote this. Please ignore that comment and forgive me for
attempting to multitask over a sandwhich and db2. :-)

ken
Nov 12 '05 #5

P: n/a
kk
Thanks for the suggestions. I haven't worked with db2 in a long time
(although I tried hacking it to get it to run on my RH9 box several
months ago...with no success) I was under a time crunch due to
requirements changing daily (ugh!). I'd prefer to write everything in
python (or C#..nice plugin for VS.net) but just not enough time. I
changed my load to an import and used insert_update to ignore
duplicates via my PK. Nice to know that ! gives os commands.

Keith
ke******@yahoo.com (Ken) wrote in message news:<ea**************************@posting.google. com>...
ke******@yahoo.com wrote:
No


Shoot, just realized that I was thinking about extracts, not imports
when I wrote this. Please ignore that comment and forgive me for
attempting to multitask over a sandwhich and db2. :-)

ken

Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.