This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

One to many insert with iBatis  RSS feed

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
Consider these two tables: Order and OrderItem.
The relationship is one to many.
To save an order, two SQL command should be executed:
Insert a row in Order table (ORDER_ID is auto generated).
Insert a row in OrderItem table (OI_ID is auto generated and the primary key of the previous insert is needed in this command).
I'm trying to adopt iBatis and MySQL as the database.
The problem is I don't know how to get the PK of the first row in order to be passed to the second row?
Any ideas?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!