You can use
the below query to get the last sql executed based on last sql which was active
in database
select ltrim(sq.sql_text)
from
v$sql sq, v$session se, v$open_cursor oc
where
sq.sql_id = oc.sql_id
and
se.saddr = oc.saddr
and
se.sid = oc.sid
and
se.audsid = SYS_CONTEXT('userenv', 'sessionid')
order
by oc.LAST_SQL_ACTIVE_TIME desc;