MySQL Forums
Forum List  »  NDB clusters

Re: NdbApi setValue does not support decimal type?
Posted by: Jacky Huang
Date: June 12, 2012 08:34PM

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)

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->equal("CUSTOMERID", 10000);
myOperation->setValue("TAX", 1.1234);
if (myTransaction->execute( NdbTransaction::Commit ) == -1)

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 & decimal_utils.hpp, but I don't know how to implement; and I have not use something in memcache code yet.

Options: ReplyQuote

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.