List:Cluster« Previous MessageNext Message »
From:Johan Andersson Date:November 28 2012 4:41pm
Subject:Re: NDB API: PK Autoincrement
View as plain text  
Hi Mazen,


      unsigned long long autoValue=1;

        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åudd
<magnus.blaudd@stripped>wrote:

> Hi,
>
> you need to use Ndb::getAutoIncrementValue() to fetch (and reserve) one or
> 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 tables
> since there is an extra roundtrip  consumed when fetching the autoincrement
> 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 64
> 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 the
>> 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
>
>

Thread
NDB API: PK Autoincrement Mazen Hajri28 Nov
  • Re: NDB API: PK AutoincrementMagnus BlĂ„udd28 Nov
    • Re: NDB API: PK AutoincrementJohan Andersson28 Nov