Solved

bcp return code?

Posted on 2002-07-03
1
1,147 Views
Last Modified: 2011-04-14
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
Comment
Question by:brianon
1 Comment
 
LVL 5

Accepted Solution

by:
amitpagarwal earned 200 total points
ID: 7129318
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Note: This is the second blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   Every month t…
Note: This is the third blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   We’ve been talki…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now