Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    136

    Unanswered: To get hostname from the database

    Hello All!

    How can i get a station_id or hostid from the database?

    E.g. i can get username calling statement like:

    select user from dual;


    Thanks in advance!
    Regards,
    Julia

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    which host? client or DB server?
    In either case it can be found in V$SESSION
    but in different fields depending on which you want.
    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
    Feb 2004
    Location
    Germany
    Posts
    136
    I want to write a procedure that has an exception creating an errorlog like this:

    PHP Code:
    EXCEPTION
        WHEN e_TooManyReservations THEN
             
             ErrorCode 
    := SQLCODE;
             
    ErrorMsg := SQLERRM;
             
    ErrorDesc := 'There are '|| NumAvail || ' features available'
             
    ErrorText := SUBSTR(SQLERRM1200);
             
    HostId := ??????????; 
             
             
    INSERT INTO ERRORLOG (
                                     
    ERROR_CODE
                                  
    ERROR_TYPEERROR_FORMPROC_NAMEPARAM
                                  
    ERROR_MSGERROR_DESCRIPTIONERROR_TEXT
                                  
    HOSTID)
                            
    VALUESErrorCode
                                  
    'DATABASE''PROCEDURE''PRC_INS_RESERVE''pNumLic'
                                  
    ,  ErrorMsgErrorDescErrorText
                                  
    HostId); 
    With HostId i mean name of workstation or pc or hostid from that the error occured.
    E.g. if i want to do this with user, i can realize this with

    PHP Code:
    select user from dual
    Do exist any possibilities to realize it?


    Thanks in advance!
    Regards,
    Julia

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    The field you want is "MACHINE" from the V$SESSION view.
    Your next challenge is to determine the Session ID (SID)
    for the current session so you can SELECT the correct
    record from v$SESSION.
    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.

  5. #5
    Join Date
    Apr 2002
    Location
    California, USA
    Posts
    482
    ... or you can use:

    SQL> select sys_context('USERENV','HOST') from dual;

    SYS_CONTEXT('USERENV','HOST')
    ---------------------------------
    DF-CORP\MATRIX


    HTH,

    clio_usa - OCP 8/8i/9i DBA

  6. #6
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    136
    Thank you both,
    it works!
    Regards,
    Julia

Posting Permissions

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