MySQL Forums
Forum List  »  NDB clusters

NdbApi setValue does not support decimal type?
Posted by: Jacky Huang
Date: June 08, 2012 02:13AM

Hi all,

I set the a colummn type as 'decimal(18,4)' in a table structure. When I use Ndb Api NdbOperation::setValue(const char* anAttrName, double aPar) to insert a value(for example: 3.14 or any value) to database, but the value showed from database is 0.

I tried to alter the column type to double, it worked correct. So I doubt setvalue does not support decimal type ??

Please help me if you know something, thanks.

Code:
NdbOperation *operation;
...

NdbTransaction *myTransaction= ndb->startTransaction();
if (myTransaction == NULL) APIERROR(ndb->getNdbError());

operation = myTransaction->getNdbOperation(table);
if (operation == NULL) APIERROR(myTransaction->getNdbError());

operation->insertTuple();

//Primary Key
Int64 customerid = 2001;
operation->equal("CUSTOMERID", customerid);

//Indeed TAX is as "decimal(18,4)" in data table structure.
//Why the tax value to database is 0 ??
double tax = 11.1234;
operation->setValue("TAX", tax);

if (myTransaction->execute( NdbTransaction::Commit ) == -1)
APIERROR(myTransaction->getNdbError());

ndb->closeTransaction(myTransaction);



Edited 2 time(s). Last edit at 06/08/2012 03:13AM by Jacky Huang.

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.