Re: NdbApi setValue does not support decimal type?
Hi Bernhard Ocklin,
My question is how to use NDB API to insert a value into an attribute of decimal data type in database, this case likes follow.
1,create a table with decimal data type, please note TAX attribute.
create table IN_CUSTOMER
(
CUSTOMERID bigint not null,
TAX decimal(18,4) null,
primary key (CUSTOMERID)
)
ENGINE=NDB
;
2, use NDB Api to insert a tuple to above table.
...
const NdbDictionary::Table *myTable= myDict->getTable("IN_CUSTOMER");
NdbTransaction *myTransaction= myNdb->startTransaction();
NdbOperation *myOperation= myTransaction->getNdbOperation(myTable);
myOperation->insertTuple();
myOperation->equal("CUSTOMERID", 10000);
myOperation->setValue("TAX", 1.1234);
if (myTransaction->execute( NdbTransaction::Commit ) == -1)
APIERROR(myTransaction->getNdbError());
myNdb->closeTransaction(myTransaction);
...
3, there is a strange thing happened in database, the value of attribute "TAX" is "0" whatever I inserted with NDB API, it should be 1.1234 in this case.
I have read what you reminded me in DataTypeHandler.cc & decimal_utils.hpp, but I don't know how to implement; and I have not use something in memcache code yet.