:Wayne Atchley schrieb in Nachricht
<9925BBBA1F247025.4B6704FAE294A17E.6B437B194D22F...@lp.airnews.net>...
:I have an application that uses CreateProcess to run the IMP73 Oracle
import
:utility. This utility let's you re-create tables and data in the Database
:from a Dump file that you can export from ORACLE.
:
:My Question: How can I trap the errors that occur during the process and
:handle them in my calling application? Currently, if the IMP73 program
:fails, the process terminates and I have no way of telling if the process
:completed under normal conditions or if it errored out.
:
:Any help is appreciated.
:
:Wayne
:
Hi, Wayne.
If I'm right-informed, IMP73 runs in a DOS box, isn't it?
If yes, it might be a "simple" problem of redirecting the output of the
IMP73 program to anywhere or anything you can access by your application.
The one way is to use the LOG parameter of IMP73 and right all output to a
logfile and search this logfile for error messages after completion of the
IMP73 program.
This might be the easiest way.
Another way is to redirect the standard output to files.
This can be done with the StartupInfo structure of the CreateProcess call.
Here's an example by Ed Hillmann, posted on 12 Aug 1999:
(Thanks, Ed!)
Quote
>-------------------------- Start of copy --------------------------<
Von: Ed Hillmann <e...@mincom.com>
Betreff: Re: Redirect dos output
Datum: Donnerstag, 12. August 1999 04:27
In the CreateProcess API call, there is a parameter that allows you to
supply StartUp parameters. You can populate it using a TStartUpInfo class
(which is the same structure as the WinAPI StartupInfo structure).
On the StartUpInfo structure, there are fields that allows you to assign
handles that should be used when accessing Input, Output and Error data
(hStdInput, hStdOutput and hStdError respectively). In addition to
assigning to these value, you must update the dwFlags attribute of
StartupInfo, or-ing it with STARTF_USESTDHANDLES.
So, I've got a function here that allows me to pass in a command-line which
in turn passes it along to the system. I've added three parameters to that
procedure, allowing the Delphi code to pass in StringLists: one for input,
one for output and one for errors.
My procedure first creates three temporary files, and uses them to map
between the stringlists and the input/output/error data from the command
line. The code that sets up my StartUpInfo structure looks like:
var
lpStartupInfo: TStartupInfo
begin
...
with lpStartupInfo do begin
...
dwFlags := dwFlags or STARTF_USESTDHANDLES;
hStdInput := HStdInCaller;
hStdOutput := HStdOutCaller;
hStdError := HStdErrCaller;
end;
The handles are return values from the CreateFile API call I did with the
temporary files I generated.
In your case, I'm guessing that you'd want to assign the hStdOutput value to
the handle of your application. I haven't tested this. But the file code
above works.
Hope this helps,
Ed
Quote
>-------------------------- End of copy --------------------------<
Whereever you write the output of IMP73 to, you can look there for words
like "warning" or "ORA-" or something.
The last line of the import's output normally contains something like
"Import completed successfully without warnings" or "Import completed
successfully with warnings" or something.
Hope this helps a bit, too.
Matthias.