[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1160
  • Last Modified:

bcp return code?

OK. So I've got a problem.....

I've written a C app that bcps files into tables in a SYBASE Database. I'm working with Solaris OS(Unix).

The problem is that if the bcp does not work my app does not know of the bcp failure !
The files get backed up and the information has to be manually retrieved.

If the bcp problem is about the file i.e. incorrect fields then my bcp operation creates a bcp error file which I check for and can then NOT backup the files etc...

However, the BIG problem is that should the bcp operation fail for another reason, say...the BULKCOPY option was not set to TRUE in the database then although an error message is displayed on screen, no error file is created and therefore my app thinks everything wen't fine and backs up the file :(

Is it possible to get return codes from bcp when I am calling it like so ..

system("bcp .....");

Any ideas?

Cheers,
Brian.
0
brianon
Asked:
brianon
1 Solution
 
amitpagarwalCommented:
You can approach your problem in a different manner.

Before doing the BCP you can find out how many rows the bcp file has ..

Then after the bcp routines are executed, just count the number of rows that are bcped ..

if the two match .. your bcp was successful..

OR

if you use your approach ..

i use the following in perl .. similar should be in C

$status = system("bcp ....") ;
if ($status eq "0")
 { print "\n Lookup Table data bulk copied to a file" ; }
else
 { die "\n Error in getting data for lookup table ." ; }

Thanks.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now