lsrzj wrote:Thanks for your answer. What you mean with row by row? Can you give me a snippet of both examples you gave me? It's just because I never did the way you are proposing, so I don't know how to accomplish this.
Best regards!
Sorry, but I have no snippets available. And unfortunately at the moment I'm rarely in the occasion of spending some time with my zeoslib development machine.
The first solution is more or less this:
- Set up the connection->no autocommit
- Set up a master ZQuery -> no CachedUpdates
- Set up the 2 detail zqueries and link them using the linkfields properties (don't know the exact name) -> don't think cachedupdates hurt here (but why mix ?)
- Append a row to the master and post -> this should write an insert to the db and retrieve the autoinc value on mysql and FB
- Append a row to the childs and post -> there the link field values should be automatically entered by the linkfields properties
- Connection.Commit.
If there's no join in the zquery.sql properties it's not necessary to use ZUpdateSQL betcause the ZQUeries can consrtruct the update statements automatically.
The second solution:
- Set up the connection->no autocommit
- Set up one ZQuery, retrieving all the fields of master and both details
- Write a database procedure insert_person with input parameters containing all columns of your query
- Set up an ZUpdateSQL component linked to the ZQuery and set insertsql to 'call insertperson(:NEW.Name,:NEW.firstname...)' (Eventually you can also use this for an update function, a delete function and a refreshsql statement)
- Open the ZQuery
- ZQuery.appendRow
- ZQuery.post --> this should call the database procedure
- Commit
The disadvantage of this procedure is that it does not retrieve the autoinc values, unless you can use the refreshsql property using a sql statement with another unique key to locate the master record that's just inserted.
I hope this can put you on the right track...
Mark