Bcp command error in uploading data to Sybase


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bcp command error in uploading data to Sybase
# 1  
Old 10-02-2018
Bcp command error in uploading data to Sybase

Hi All,

I had an issue in executing bcp command to connect to Sybase from Unix script for uploading the data from file to table.

I have a file called vrs_temp.txt (with two columns):
Code:
22055;20181001
21088;20181001
93840;20181001
30990;20181001
50990;20181001
50950;20181001

Created a table using isql command (with three columns - the third one should be null in database). Then used bcp command to insert the data:

1st Error:
Code:
bcp $db..table_name in vrs_temp.txt -U$Login -PPASSWD -S$DBName -c -t\\;


by using the above command I have got the below error and it doesn't uploaded the date into table.
Code:
Starting copy...
Unexpected EOF encountered in BCP data-file.
bcp copy in failed

2nd Error:
Code:
bcp $db..table_name in vrs_temp.txt -U$DBLogin -PPASSWD -S$DBName -c -t\;


The error I got was :
Code:
Starting copy...
CSLIB Message:  - L0/O0/S0/N24/1/0:
cs_convert: cslib user api layer: common library error: The conversion/operation was stopped due to a syntax error in the source field.
CSLIB Message:  - L0/O0/S0/N36/1/0:
cs_convert: cslib user api layer: common library error: The result is truncated because the conversion/operation resulted in overflow.

Could you please check and let me know the problem in the command.

Thanks.




Moderator's Comments:
Mod Comment Please use CODE tags - for data as well - as required by forum rules!
And, don't (over)use text colouring.

Last edited by RudiC; 10-02-2018 at 07:47 AM.. Reason: Added CODE tags.
# 2  
Old 10-02-2018
Just an idea. Try changing in the txt file the EOL character to CRLF or vice versa. (some version of dos2ux or ux2dos).
# 3  
Old 10-03-2018
Sorry, I didn't understand could you breif the idea you are proposing.

Thanks
# 4  
Old 10-03-2018
Quote:
Originally Posted by Suresh
Sorry, I didn't understand could you breif the idea you are proposing.
UNIX (and similar OSes linke Linux) and DOS (and its successors linke Windows) have different ways of ending lines in a text file. Somehow software has to know that e.g. in:

Code:
first line
second line

after the "e" of "first line" this line ends and a new line begins. Otherwise it would all be one line. DOS/Windows does this with a 2-character sequence (in hexadecimal notation: 0x0D 0x0A, a "carriage return" character, followed by a "linefeed" character), whereas UNIX does it with a 1-character code (a "newline" character). dos2unix and unix2dos are two programs which convert files from one format to the other, according to their name. rdtx1 suggested you should use one of them because maybe the file you have is in the wrong format for your system (DOS version on a UNIX system or vice versa).

I hope this helps.

bakunin
# 5  
Old 10-04-2018
Thank you. Actually the problem is with the file format at end of each line. So, I have added a semicolon delimiter and tried accessing the bcp command to load the data into Sybase.

Code:
awk -v d=`date +%Y%d%d";"` -FS="," -vOFS=";" '{$2=d; print $1,$2}' temp.txt > new_file.txt

22055;20181004;
21088;20181004;
93840;20181004;
30990;20181004;
50990;20181004;
50950;20181004;

bcp db..table_name in new_file.txt -U$Login -PPASSWD -S$DBName -c -t";"

Copied 11 rows to database

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

bcp error

hi all, Getting error while working on sybase::bcp as below, DB-Library error: Attempt to convert data stopped by syntax error in source field. Code is like, my $bcp_files = new Sybase::BCP $usr, $pass, $server; ---------- Post updated at 02:05 AM ---------- Previous update... (0 Replies)
Discussion started by: Deei
0 Replies

2. Shell Programming and Scripting

bcp command help

Hi, When i execute a script in unix, the result i got is :: ./purgeErrors.ksh: bcp: not found What is the meaning of that output ? --- Aditya (9 Replies)
Discussion started by: chaditya
9 Replies

3. Shell Programming and Scripting

sybase::bcp

I am trying to bcp in using sybase::bcp perl module. I can find we can give user, pwd and server name in the parameters. How can I give database and table name? (1 Reply)
Discussion started by: Deei
1 Replies

4. Shell Programming and Scripting

BCP command or module

Hi All, I am trying to bcp in data file into database. now there is bcp command available in unix and another perl module Sybase::BCP is also available. Can anyone please let me know if there is any limitations of bcp command in unix. whichever is good to use? (1 Reply)
Discussion started by: Deei
1 Replies

5. UNIX and Linux Applications

Sybase help: Open client, bcp function

To begin: I use Linux The Problem: I need bcp functionality for scripts. Perl modules, such as Sybase:xfer, require ctlib which comes with Sybase Open Client. Talking with Sybase sales reps is an exercise in futility and hate. They know absolutely nothing about their own products and will... (0 Replies)
Discussion started by: Bubnoff
0 Replies

6. Shell Programming and Scripting

fetching data from sybase using perl

How can I fetch and retreive data(of each result set) of multiple result set from sybase by calling a stored procedure using perl DBI module on an unix solaris environment????? Please help (3 Replies)
Discussion started by: wadhwa.pooja
3 Replies

7. Shell Programming and Scripting

get the data from sybase and append to the file

How to get the data from the sybase database and append the data obtained into the file. For example, I will get the filename 'temp' from the database. This filename is associated with the number 1.6... This number 1.6 needs to be copied into the file that matches the filename in the... (1 Reply)
Discussion started by: vinay123
1 Replies

8. UNIX for Advanced & Expert Users

Need a script for uploading data from unix box to mysql databse

how to upload system information(unix box) to MySql database's(running in another unix box) respective tables using a script only..i.e once script runs all the informations like hostid,hostna,disks,cpu etc get stored to respective tables of MySql database.... (2 Replies)
Discussion started by: shubhendu.pyne
2 Replies

9. Shell Programming and Scripting

Data transfer from DB2 to Sybase using Perl?

Hi, Good Morning everybody. I need to write a perl script which will get some data from DB2 table and then put it into Sybase table. I have the experience in Oracle and Unix but new to these perl, DB2 and Sybase technologies. Appreciate if any one can suggest with a sample code. Thanks... (1 Reply)
Discussion started by: rajus19
1 Replies
Login or Register to Ask a Question