Android Question How do I use DBRequestManager in batch execution for parent-child records?

Steve Miller

Active Member
Licensed User
Longtime User
I need to insert into 5 tables in a SQL Server database. I'm using the RDC, which is awesome!
Here is my scenario.

I need to insert into a table called Customer. The key is ID, which is an identity column. I have a stored procedure on the database I can use for this and it will return the ID created.
Once the customer is inserted and I have the ID for the new customer, I need to insert into 4 more tables, with the key for each table being the ID from the customer insert.

So, my questions are:

1. How do I call a stored procedure using RDC and DBRequestManager?
2. I'd like to make use of the "ExecuteBatch" command of DBRequestManager, as it is faster and will wrap all the inserts in a transaction. How do I do it, if I have to get the ID from the first insert to be used in the remaining 4 inserts? Again, I'd like to make use of stored procedures on the remote server, if I can.
 

incendio

Well-Known Member
Licensed User
Longtime User
2. You can use an Insert with Select. For example: http://www.w3schools.com/sql/sql_insert_into_select.asp

I need this too, but may be can't be done this way, cause the child table only need specific parent id from the first insert.

How to formulate select sql if we don't know the criteria to select specific id from parent table? Without a criteria, all id from parent table would be selected.
 
Upvote 0
Top