Re: [dabo-users] Importing data to linked tables

Author: Charles Brunet

Posted: 2012-05-03 at 12:39:44

2012/5/3 Paul McNett <p@ulmcnett.com>

> On 5/3/12 5:09 AM, Charles Brunet wrote:

> > I will try to manually set the PK value, as you

> > suggest. But how can I get the last insert ID? This function exists in

> the

> > cursor class, but not in the bizobj class. Or should I query the DB to

> get

> > the max value for the PK field? Even that I'm not sure how to do it.

>

> You can't ask the database for the last insert id until the database has

> inserted the

> record. The database won't insert the record until you call biz.save(),

> which you

> don't want to do inside the loop. You also don't want to guess at what the

> database

> will assign for the key because another user could have beaten you to it,

> among other

> reasons.

>

> Do you want me to tell you how to use uuid's for your key fields? This

> would require

> redefining the database to use char(40) keys and not auto-increment.

Well, I misunderstood what you meant by UUID. Now I understand.

What I was looking for was to get the last insert id before importing the

data, and then simply to increment the id for each imported row. But Ed's

solution is simpler, safer, and better.

Charles.

--- StripMime Report -- processed MIME parts ---

multipart/alternative

text/plain (text body -- kept)

text/html

---

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/CAJPgzx=qvyOkrO3a5WUV=eHr0ebVmYq6UOgX=otBe4QZW81uPg@mail.gmail.com

©2012 Charles Brunet