How to get the currval for all sequences in one SQL query

I need a sql query that will give me the currval of all sequences in one go. How might I do that? I'm only aware of how to get currval like this:

SELECT MySequence.CURRVAL from dual;

Thanks for any assistance.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
CURRVAL is only good for the same session that executed NEXTVAL.

Look at user_sequences:
select sequence_name, last_number from user_sequences;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nanderEireAuthor Commented:
but isn't that the last number in the cache, not necessarily the current number?
slightwv (䄆 Netminder) Commented:
current number is relative to the session that created it.

Log into sqlplus from two separate windows and do the following:

select mySeq.nextval from dual;
select mySeq.curval from dual;

Both windows will show a different CURRVAL.
IF you have called nextval for every sequence then you could try something like this...

SELECT sequence_name,
DBMS_XMLGEN.getxmltype('select ' || sequence_name || '.currval from dual'),
current_value FROM user_sequences;

note, all caveats detailed above by slightwv still apply here,

if any of the sequences have NOT been defined by a call to nextval you'll get an ORA-8002 when you try to query currval
oops ,small correction to query above ( I forgot the alias x )

SELECT sequence_name,
DBMS_XMLGEN.getxmltype('select ' || sequence_name || '.currval x from dual'),
FROM user_sequences;
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.