Active_routine_name

SQL

function Active_routine_name(IN level INT); returns CHAR(67);


Parametry

level
distance of the calling routine


Od verze

8.0

Popis

This function gets and returns the name of the routine (procedure or function), which (directly or indirectly) called the currently running routine. If level equals 1, the function will return the calling routine. The function returns more distant routines for higher values. If level equals 0, the function will return the currently running routine. If level is negative, NULL or higher then the count of calling routines the function will return an empty string.

The function serves for diagnostic purposes, e.g. in handlers.



Návratová hodnota

The returned routine name is in the form `scheme_name`.`routine_name`.



Příklad

This function logs the order of running routines.

declare procedure Call_stack();
begin
  declare i int;   declare name char(67);
  set i=0;
 cycle:
  loop
    set name=Active_routine_name(i);
    if name IS NULL then leave cycle; end if;
    call Log_write(name);
    set i=i+1;
  end loop;
end;