corser
07-17-2002, 08:20 AM
HI, I have a problem...really not only one...How can I obtain the ip address with plsql????
Thanks in advance,
Thanks in advance,
|
Click to See Complete Forum and Search --> : ip corser 07-17-2002, 08:20 AM HI, I have a problem...really not only one...How can I obtain the ip address with plsql???? Thanks in advance, stecal 07-17-2002, 12:35 PM 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. corser 07-18-2002, 06:46 AM Thanks a lot! ....ops... I have create function ip...now ?????? I'm startin use oracle and plsql monday!!!! stecal 07-18-2002, 12:32 PM You have the code (in my previous post) to create the function. Shouldn't be any problem. corser 07-19-2002, 05:08 AM 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?? stecal 07-19-2002, 12:31 PM 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; corser 07-22-2002, 06:26 AM 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... tamilselvan 07-22-2002, 02:36 PM 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. corser 07-23-2002, 06:03 AM 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! dbasupport.com
Copyright Internet.com Inc. All Rights Reserved. |