set verify; create module LIB_ROUTINES language SQL procedure LIB$GETJPI (in :item_code integer by reference ,inout :process_id integer by reference ,in :process_name integer by value ,out :resultant_value integer); external name LIB$GETJPI location 'SYS$SHARE:LIBRTL.EXE' language GENERAL GENERAL parameter style bind on client site comment is 'LIB$GETJPI' / '--' / 'The Get Job/Process Information routine provides a' / 'simplified interface to the $GETJPI system service. ' / 'It provides accounting, status, and identification' / 'information about a specified process.' / 'LIB$GETJPI obtains only one item of information' / 'in a single call.'; function CURRENT_PID returns integer comment is 'A jacket function to return the results from LIB$GETJPI'; begin declare :JPI$_PID constant integer = 793; declare :in_pid, :out_pid integer; call LIB$GETJPI (:JPI$_PID, :in_pid, 0, :out_pid); return :out_pid; end; end module; -- The function is now used as shown select CURRENT_PID () from rdb$database;