IP Address

Scripts Diversos para o Oracle SQL*Plus. (Relacionado a ferramenta Oracle SQL*Plus, para questões de SQL, usar o forum SQL)
Post Reply
ANDREGOUVEIA
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Posts: 7
Joined: Mon, 25 Jul 2011 8:40 am
Location: FORTALEZA

Dear,

I need to get the IP address of a client machine, Duranta running a procedure that is in a package in the bank. Does anyone have any idea how to do it?

In Forms I use the Web_util.clientinfo.get_ip_address package;
I'vê also tried this select, but the result is not my machine's address.

Select all

select SYS_CONTEXT('USERENV', 'IP_ADDRESS', 15) ipaddr from dual

Thanks,

ATT, [99]
André Gouveia.
User avatar
stcoutinho
Moderador
Moderador
Posts: 850
Joined: Wed, 11 May 2011 5:15 pm
Location: são Paulo - SP

Hello Andrégouveia,

With this querie, you identify the IP of the server where the database is located:

Select all

SELECT UTL_INADDR.GET_HOST_ADDRESS(HOST_NAME), HOST_NAME FROM V$INSTANCE;
with this other querie , you identify the IP address of a SQL * Plus client session:

Select all

SELECT SYS_CONTEXT( 'USERENV', 'IP_ADDRESS' ) FROM DUAL;
This queries above will return null, if the session is not using TCP / IP on the connection.

You can also have an overview of all existing bank sessions:

Select all

SELECT SID,OSUSER,TERMINAL FROM V$SESSION;
Now, see. About this procedure that you say exist in the database: how is it exactly executed? Who executes it?

Let's say that this command is in your procedure:

Select all

SYS_CONTEXT( 'USERENV', 'IP_ADDRESS' )
If for example you open a sql * plus session on your machine and call The procedure, the SYS_Context should return exactly the IP address where you started your SQL session (your workstation).

But in case your procedure is performed by some web application, the maximum you will be able to get will be the IP address of the application server that started the database SQL session.

We still say that your procedure is triggered by a job within the database (dbms_job). The returned IP address will be that of the database server itself.

I hope I have helped clarify your doubts. Feel free to make more questions,

Hugs,

Sergio Coutinho
User avatar
stcoutinho
Moderador
Moderador
Posts: 850
Joined: Wed, 11 May 2011 5:15 pm
Location: são Paulo - SP

Um ...

I had not noticed one thing .. Did you say you're trying to take a test with the forms .. Would it be he who performs this procedure?

I believe that in this case you can only get the Forms server address if you use this SYS_Context function.

Hugs,

Sergio Coutinho
JLMANA
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 13
Joined: Tue, 22 Nov 2011 8:22 am

Create the routine in your forms as follows:

Select all

DECLARE 
  V_RETORNO		VARCHAR2(50); 
BEGIN 
    SELECT SYS_CONTEXT ('USERENV', 'IP_ADDRESS')  
    INTO V_RETORNO 
    FROM DUAL; 
END;
ANDREGOUVEIA
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Posts: 7
Joined: Mon, 25 Jul 2011 8:40 am
Location: FORTALEZA

Dear,

Thanks to everyone who collaborated with the problem presented, but no suggestions worked. Because the return is always being in relation to the database, either the server address, or client session. In my case, I would need a similar function Web_util.clientinfo.get_ip_address, which in Forms returns the IP address of my machine.

Att,

André Gouveia.
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 16 guests