|Just another Perl shrine|
Re^6: SELECT LAST_INSERT_ID does not workby erix (Parson)
|on Jul 01, 2017 at 21:25 UTC||Need Help??|
Oracle's RETURNING clause is simply the best way to do it.
I think PostgreSQL's RETURNING clause is far, far better.
Oracle's way forces you to read the values into variables that you also have to define beforehand:
(Oracle12 docs:) "For each expression in the RETURNING list, you must specify a corresponding type-compatible PL/SQL variable or host variable in the INTO list."
Yuck, that's awful. That's really not handy.
It seems the objections mentioned in this old SO thread are still valid.
By the way, postgres has had INSERT ... RETURNING since v8.2 (2006). I rather suspect that Oracle's kludgy PL/SQL-based imitation was bolted on after that, and because of it. (Well, maybe 'kludgy' is too harsh. But the above disadvantages certainly make it imperfect compared with Postgres.)