Re: EDS Autonumber

new topic     » goto parent     » topic index » view thread      » older message » newer message

cklester wrote:
> 
> Matt Lewis wrote:
> > cklester wrote:
> > > Greg Haberek wrote:
> > > > global function db_next_key()
> > > >     integer count
> > > >     count = db_table_size()
> > > >     if count = 0 then
> > > >         key = 0
> > > >     else
> > > >         key = db_record_key( count )
> > > >     end if
> > > >     return key+1
> > > > end function
> > > You'd need something like
> > >    while keyExists( count ) do
> > >         count += 1
> > >    end while
> > > so as to avoid duplicate keys in cases where records get deleted.
> > 
> > No, his method would work fine, because EDS always keeps the records sorted
> > by key, so the last record is guaranteed to be the highest number currently
> > in the table.  Note that count is the record number of the last record, and
> > key is the acutal key value.  Of course, you'd need to define 'atom key'
> > to make this routine work...
> 
> Oh, I see. I misread and thought he was just using the size, like Rob said.
> 
> -=ck
> "Programming in a state of Euphoria."
> <a
> href="http://www.cklester.com/euphoria/">http://www.cklester.com/euphoria/</a>

But, I thought that EDS refills deleted records, thus them not being sorted?

Thanks,
 Alex

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu