Does NDB API support varchar type?
Hi,
I'm trying to insert data into a table that has varchar type columns with NDB Api. Each time I got errors when commit the transactions. But if I change the column type to char type, it can do well.
I wander if NDB Api support varchar type or I made mistakes in my programm?
Following is my table structure and my ndb api codes:
if (mysql_query(&mysql,
"CREATE TABLE"
" MYTABLENAME"
" (ATTR1 int not null primary key,"
" ATTR2 varchar(20) not null)"
" ENGINE=NDBCLUSTER"))
ndbapi codes:
char str[20];
NdbTransaction *myTransaction= myNdb.startTransaction();
if (myTransaction == NULL) APIERROR(myNdb.getNdbError());
NdbOperation *myOperation= myTransaction->getNdbOperation(myTable);
if (myOperation == NULL) APIERROR(myTransaction->getNdbError());
myOperation->insertTuple();
myOperation->setValue("ATTR1", 1);
sprintf(str,"abc");
if (myOperation->setValue("ATTR2", str)==-1)
{
printf("set ATTR2 wrong.\n");
//if ATTR2 is varchar(20), this error comes up.
exit(-1);
}
if (myTransaction->execute( NdbTransaction::Commit ) == -1)
APIERROR(myTransaction->getNdbError());
myNdb.closeTransaction(myTransaction);
Subject
Views
Written By
Posted
Does NDB API support varchar type?
1825
November 21, 2006 09:08PM
1031
November 22, 2006 06:31AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.