Check query execution to go further

Can any one help with script (Korn) to do following ? :confused:

I have 3 tasks to do in a shell.

Task (1) is executing query which unloads the result into file XYZ.

Before I start Task (2) which is java program and depends on
file XYZ, I need to make sure that Task (1) is completed successfully.

Before I start Task (3) which has to do with emailing file XYZ, I need to make sure Task (1) & (2) run successfully.

Questions:

[1] How can I check whether my query run successfully or not ?
[2] How can I check that my java program runs successfully and created another file which it supposed to?
[3] How can I check whether email has been sent successfully or not ?

Quick response will be great help !!!

See your other thread