I create a procedure for insert statement with some input parameters. But i want to get the inserted id or inserted row from the same procedure.I created using oracle, that is working fine. But i don't know in mysql. And spend more time to get this.i can't.
Asked
Active
Viewed 234 times
1 Answers
1
MySQL solution:
After running the insert
statement, execute
select last_insert_id() into lastId;
Change your SP to include an OUT
parameter as
OUT lastId bigint
or simply run
select last_insert_id();
to return a result set by the SP;
Refer to:
- MySQL: LAST_INSERT_ID()
- Value of the AUTOINCREMENT column for the last INSERT

Ravinder Reddy
- 23,692
- 6
- 52
- 82