Auto_inc field and stored procedure

I have a stored procedure which adds a record to a table with an auto_inc field if the passed in ID is 0 (and updates it if it is > 0). The insert works correctly; the auto_inc field populates correctly (automatically).

The problem is that I would like to return the ID value (generated in the auto_inc field). I've tried several ways, including LAST_INSERT_ID(), but it does not get the value. Once the stored procedure completes, I can get the value, but I cannot while execution is still within the stored procedure.

I assume this is some latency or data commit problem, perhaps a setting or other command/code I need to do? Or is this working "as designed", and I need to shell out to a sub stored procedure to make this work the way I want?