I have a project where I need to do 4 inserts in a MySQL database in a single transaction. One of the requirements is using lastInsertID to obtain the primary key (it’s an auto_increment field), so that subsequent inserts will properly link records between tables. For example, in table A, after an insert, the primary key (ID) might be 57 for the last record inserted. In Table B, when a new record was inserted, a field called table_a_id would need to use the value 57 (lastinsertID obtained from the Table A insert). A similar step is required after a Table B insert when inserting a new record in Table C.
I can do this in an external PHP page, but I would like to use a SC form to ask a question (Yes or No), record the response in a different table, and based on that response, complete the transaction described above (on a different set of tables). Pseudo code: if ({answer} == 'Y") { Do Transactional Inserts}. I would place this code inside the onAfterInsert event in the form.
Can I access lastinsertID using a SC macro? I am not sure that sc_select, which exposes an ADO recordset has a lastinsertID method. Any advice would be appreciated.