Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2006

    Unanswered: where does session id come from?

    the oracle version of where do babies come from?, except i don't expect stork as an answer ;-)...

    basically, the thing is i have a stored proc i call through dbms_jobs. Now, i want to get the session ID of oracle into this SP. So i did this:

    l_session_id := USERENV('SESSIONID');

    insert into table (...,l_session_id);

    But i always get the value '0' in it...why? I have used this methos in a lot of SPs and they have worked. Only this one is being called using dbms_job.

    One more question. What is the difference between USERENV('SESSIONID') and the SID that we get from v$session, and is there a v$ table where i can find the value of session id same as USERENV('SESSIONID')???

  2. #2
    Join Date
    Aug 2003
    Where the Surf Meets the Turf @Del Mar, CA
    Provided Answers: 1
    12:29:47 Sql> Select Dbms_support.mysid From Dual;

    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    May 2004
    Dominican Republic
    This is because jobs processes (JNNN) which are the processes that launch your job's procedures are not owned by the user that submit the job, but rather SYS and since their sessionid will always be 0.

    userenv('sessionid') returns your auditing session id, not your session id. Match that with AUDSID on v$session.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts