Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unique id for each execution #256

Open
at-ng opened this issue Mar 29, 2022 · 0 comments
Open

Unique id for each execution #256

at-ng opened this issue Mar 29, 2022 · 0 comments

Comments

@at-ng
Copy link

at-ng commented Mar 29, 2022

It's nice to have an identifier for each separate execution (job execution, web service call etc). When a lot of things happens at the same time it can get a bit annoying to follow along in the log. You can filter on SID but then you have to also add an interval if you also want to isolate a specific execution.

I'm already using this by just having a package that uses "PRAGMA SERIALLY_REUSABLE" to be able to get an unique id. Then I have a function that sets it if it's not already set that I can call before I start logging. Currently I do this by setting client_info since I'm not using that for anything else but ideally you would want a separate column for this instead and move the call into logger so that you don't have to manually call this set id function.

Example:

CREATE OR REPLACE PACKAGE BODY exec_guid_pkg
IS
  PRAGMA SERIALLY_REUSABLE;
  g_exec_guid   VARCHAR2 (32 BYTE);

  FUNCTION get_exec_guid
    RETURN VARCHAR2
  IS
  BEGIN
    IF g_exec_guid IS NULL
    THEN
      g_exec_guid := RAWTOHEX (SYS_GUID ());
    END IF;

    RETURN g_exec_guid;
  END;
END exec_guid_pkg;

There is a disadvantage with this approach though, SERIALLY_REUSABLE excludes SQL so something else might be needed if you want it to work for that as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant