Not that I know of. There is a bit of a catch-22 here, because to probe for that SQL we must *run* SQL, which of course then becomes the currently running SQL, eg
SQL> create or replace
2 function blah(c int) return int is
3 l_sql_id1 varchar2(30);
4 l_sql_id2 varchar2(30);
5 l_sql_text varchar2(1000);
6 begin
7 select sql_id, prev_sql_id
8 into l_sql_id1, l_sql_id2
9 from v$session
10 where sid = sys_context('USERENV','SID');
11
12 dbms_output.put_line(l_sql_id1);
13 dbms_output.put_line(l_sql_id2);
14
15 return c;
16 end;
17 /
Function created.
SQL>
SQL> set serverout on
SQL> select blah(10) from dual;
BLAH(10)
----------
10
fu3ng5ux16xn2
5t10uu7v11s5t
SQL> select sql_id, sql_text
2 from v$sql
3 where sql_id in
4 ( 'fu3ng5ux16xn2','5t10uu7v11s5t');
SQL_ID SQL_TEXT
------------- ----------------------------------------------------------------
5t10uu7v11s5t BEGIN DBMS_OUTPUT.ENABLE(NULL); END;
fu3ng5ux16xn2 SELECT SQL_ID, PREV_SQL_ID FROM V$SESSION WHERE SID = SYS_CONTEX
T('USERENV','SID')
Do you need it at run time (ie, within the function) or are you just trying to detect excessive calls etc. You could do some data mining of v$sqlstats to detect executions, rows processed, etc
Even if you *could* pick it up, I'd have concerns because you generally do not want to be aggressively querying v$ structures, so even my example above would not be good if you were doing (say)
select blah(object_id) from all_objects;
because I'd be smashing v$session tens of thousands of times in the one call.