Solved

bcp return code?

Posted on 2002-07-03
1
1,152 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 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

While it may be true that the internet is a place of possibilities, it is also a hostile environment lurking with many dangers. By clicking on the wrong link, trusting the wrong person or using a weak password, you are virtually inviting hackers to …
Arrow Electronics was searching for a KVM  (Keyboard/Video/Mouse) switch that could display on one single monitor the current status of all units being tested on the rack.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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