[eluser]carlos[/eluser]
Hi,
I need some help here with a quite typical problem, but as I'm more used to java and oracle, I don't know if I'm doing it correctly:
1. I have a couple of tables - call them parent and child.
2. Parent has an ID column, which auto increments.
3. I need to insert rows in the child after inserting on the parent, using the last auto-genetated id value in the parent.
I'm doing this:
Code:
$stmt = "SELECT LAST_INSERT_ID() AS LAST_VALUE";
$last_record = $this->db->query($stmt);
if ($last_record->num_rows() > 0)
{
$row = $last_record->row();
log_message('debug', 'Last generated ID: '.$row->LAST_VALUE);
}
Is this a good way or there is a better one?
You know, once you get user to Oracle's sequence.curr_val and next_vat is difficult to switch
Thanks in advance!!
Carlos