From: Johan Andersson Date: November 28 2012 4:41pm Subject: Re: NDB API: PK Autoincrement List-Archive: http://lists.mysql.com/cluster/8450 Message-Id: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=f46d0447f260554ec204cf90d5d5 --f46d0447f260554ec204cf90d5d5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Mazen, unsigned long long autoValue=3D1; myNdb->getAutoIncrementValue(ndbtable, autoValue, 32768, 1, 1); good luck. You have to check yourself in the Ndb.hpp what the parameters to the getAutoIncrementValue method mean. Johan Andersson Severalnines AB On Wed, Nov 28, 2012 at 4:09 PM, Magnus Bl=E5udd = wrote: > Hi, > > you need to use Ndb::getAutoIncrementValue() to fetch (and reserve) one o= r > more autoincrement values for the table you are inserting into. Then use > the returned value you get in subsequent insert. > > Normally it's not recommended to use auto increment columns for NDB table= s > since there is an extra roundtrip consumed when fetching the autoincreme= nt > value using the above function. Even though you can fetch something like = 64 > values at a time, you'd get gaps in the range unless you really insert 6= 4 > rows. > > If possible try to use different primary key. Unless anything obvious is > available, you can always generate a UUID. > > Sorry, couldn't find any simple example. > > / Magnus > > > > > On 11/28/2012 02:51 PM, Mazen Hajri wrote: > >> Hello there, >> >> >> >> I'm currently implementing some application on top of NDB API, but I'm >> facing a problem of incrementing the PK with an auto_increment attribute= . >> Do >> I have to read the last value then do the auto increment explicitly in t= he >> code, or is there an easier way? >> >> >> >> A simple example would be of great help. >> >> >> >> Kind regards, >> >> Mazen >> >> >> > > -- > MySQL Cluster Mailing List > For list archives: http://lists.mysql.com/cluster > To unsubscribe: http://lists.mysql.com/cluster > > --f46d0447f260554ec204cf90d5d5--