?
Solved

bcp return code?

Posted on 2002-07-03
1
Medium Priority
?
1,156 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
amitpagarwal earned 800 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
I originally wrote this article to compare SARDU and YUMI, but have now added Easy2Boot, since that is the one I currently use and find the easiest to create and alter.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

765 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