You are here: bulk copy error: Received invalid row length x from bcp client. Minimum row size is y « MsSQL Server « IT news, forums, messages
bulk copy error: Received invalid row length x from bcp client. Minimum row size is y

Posted by Patrick Dunnigan on 09/28/05 11:19

Hi,

I am attempting a bulk copy from a c program into SQL Server 2000 using
DBLib in freeTDS 0.63 RC11 (gcc 3.4.3, RH 9). I am getting an error message
that I cannot find any documentation on.

The server is sending back the following: "Received invalid row length 2
from bcp client. Minimum row size is 4."

I know the row is longer 2 bytes (see below). Once this happened I created a
test table and C program. See below. Anyone with any ideas?

Thanks

Program output ---------------->
$ ./test_bcp
bcp'ing This is a test with a length of 14
sent
Msg 4807, Level 16, State 1
Server 'CENTIVIA_10', Line 1
Received invalid row length 2 from bcp client. Minimum row size is 4.
done
<----------------------

Table ddl --------------------->
CREATE TABLE [xxx] (
[col2] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
<------------------------------------

Compiled using gcc ------------------->
gcc -g -I/home/test_user/dev/freetds-0.63RC11/include -Wall -Wno-strict-aliasing
-g -O2 -c -o test_bcp.o test_bcp.c
gcc -o test_bcp test_bcp.o -L/home/test_user/lib -lsybdb
<----------------------------------


program source (included the msg and error handler
code) -------------------------->
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sqldb.h>
int
syb_msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity,
char *msgtext, char *srvname, char *procname, int line)
{
char var_value[31];
int i;
char *c;

if (msgno == 5701 || /* database context change */
msgno == 5703 || /* language changed */
msgno == 5704) { /* charset changed */

if (msgtext != NULL && (c = strchr(msgtext, '\'')) != NULL)
{
i = 0;
for (++c; i <= 30 && *c != '\0' && *c != '\''; ++c)
var_value[i++] = *c;
var_value[i] = '\0';

}
return 0;
}

if (severity >= 0 || msgno == 0) {
if (msgno > 0 && severity > 0) {
fprintf(stdout, "Msg %d, Level %d, State %d\n",
(int) msgno, (int) severity, (int) msgstate);
fprintf(stdout, "Server '%s'", srvname);
if (procname != NULL && *procname != '\0')
fprintf(stdout, ", Procedure '%s'",
procname);
if (line > 0)
fprintf(stdout, ", Line %d", line);
fprintf(stdout, "\n");
fprintf(stdout, "%s\n", msgtext);
fflush(stdout);
} else {
fprintf(stdout, "%s\n", msgtext);
fflush(stdout);
}
}

return 0;
}

int
syb_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char
*dberrstr, char *oserrstr)
{
if (dberr == SYBESMSG)
return INT_CANCEL;
env_set(g_env, "batch_failcount", "1");
fprintf(stdout,
"DB-LIBRARY error (severity %d, dberr %d, oserr %d, dberrstr
%s, oserrstr %s):\n",
severity, dberr, oserr, dberrstr ? dberrstr : "(null)",
oserrstr ? oserrstr : "(null)");
fflush(stdout);
if ((dbproc == NULL) || DBDEAD(dbproc)) {
if (dberr != SYBECOFL) {
exit(255);
}
}

return INT_CANCEL;
}


int main(int argc, char *argv[])
{
DBPROCESS *dbproc;
LOGINREC *login;
DBINT test_int = 99999999;
DBCHAR test_char[32] = "This is a test";

dbinit();
dberrhandle(syb_err_handler);
dbmsghandle(syb_msg_handler);
login = dblogin();
DBSETLPWD(login, "audit");
DBSETLUSER(login, "audit");
dbproc = dbopen(login, "192.168.58.1");
dbuse(dbproc, "audit_dev");

bcp_init(dbproc,"xxx", (BYTE *)NULL, (BYTE *)NULL, DB_IN);
printf("bcp'ing %s with a length of
%d\n",test_char,strlen(test_char));
//ii = bcp_bind(dbproc, (BYTE *) &test_int, 0, -1, NULL, 0, SYBINT4,
1 );
//printf("bound %d\n",ii;
bcp_bind(dbproc, test_char, 0, strlen(test_char), NULL, 0, SYBCHAR,
1 );
bcp_sendrow(dbproc);
printf("sent\n");
bcp_batch(dbproc);
printf("done\n");
return 0;

}
<---------------------------------

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация