HI, I have a problem...really not only one...How can I obtain the ip address with plsql????
Thanks in advance,
Printable View
HI, I have a problem...really not only one...How can I obtain the ip address with plsql????
Thanks in advance,
Create a trigger, program unit or store function using SYS_CONTEXT function to get the IP address.
Example:
CREATE OR REPLACE Function IP
RETURN Varchar2
IS
v_ip Varchar2(30);
Begin
Select SYS_CONTEXT('USERENV','IP_ADDRESS')
Into v_ip
From Dual;
Return v_ip;
End;
For more information on the SYS_CONTECT function refer to:
Oracle8i Application Developer's Guide - Fundamentals.
You can do Select SYS_CONTEXT('USERENV','IP_ADDRESS') from dual;
in a SQL*Plus session if all you want is your IP address.
Thanks a lot!
....ops...
I have create function ip...now ??????
I'm startin use oracle and plsql monday!!!!
You have the code (in my previous post) to create the function. Shouldn't be any problem.
The function is ok, but I want to store client' ip in a log file and in a table, so how can execute it in a procedure??
declare
client_ip varchar2(20);
begin
client_ip := select statement to get IP address
insert into table_name (IP) values (:client_ip);
Use the utl_file utility to write to a log file
end;
Ok...but there is a problem...
this is my procedure:
create or replace procedure bo is
client_ip varchar2(20);
begin
client_ip := marco();
insert into ipm values(client_ip);
htp.prints(client_ip);
end bo;
and this, my function:
CREATE OR REPLACE Function marco
RETURN Varchar2
IS
v_ip Varchar2(30);
Begin
Select SYS_CONTEXT('USERENV','IP_ADDRESS')
Into v_ip
From Dual;
Return v_ip;
End;
when i'm calling procedure by browser, client_ip is the server ip!!!
I don't know why!...can u help me?
thank u for everything...
The sys_context will not give server ip address.
Even if you run the procedure in the server machine, this will return NULL value.
The SYS_CONTEXT('USERENV','IP_ADDRESS') will work only at the client side.
i have oracle client on my machine(m1) and oracle db (8i) on another(m2)...if i run procedure on my pc using plsql dev, ip is my ip, but if i run procedure calling by browser, ip is the server ip (where oracle db is installed)
I try the use select sys_context('userenv','ip_address')ip from dual; on m2 and the result is m2' ip....
I don't know what is the problem.
thank u for your answer!