ip address in form [message #288020] |
Fri, 14 December 2007 05:52 |
annu-agi
Messages: 238 Registered: July 2005 Location: Karachi
|
Senior Member |
|
|
hi experts
i m finding a way to store ip address of machine in a variable and my coding is below
declare
string varchar2(2000);
temp_label varchar2(255);
temp_num number;
t_ipadd varchar2(20);
t_sid number(3);
begin
temp_num := nvl(pick_list.get_picklist_element_count(pick_list.list_out),0);
-- string := to_char(temp_num) || ' values: ';
select SYS_CONTEXT('USERENV', 'IP_ADDRESS', 15) into t_ipadd from dual;
select sid into t_sid from v$session where audsid=(SELECT userenv('sessionid') FROM dual);
for i in 1..temp_num loop
temp_label := pick_list.get_picklist_element_value(pick_list.list_out, i);
insert into tmp_data values (t_ipadd,t_sid,temp_label);
if i > 1 then
STRING:=STRING||CHR(39)||temp_label||CHR(39);
-- string := string || ', ' || temp_label
else
STRING:=STRING||CHR(39)||temp_label||CHR(39);
end if;
if I<>TEMP_NUM then
string:=string||', ';
end if;
end loop;
:ctrl_block.m_picklist_values := string;
end;
it give me an error
identifier sys_context must be declare .
what it means, while i m already declare the variable t_ipaddr to store the value to select
any idea .. what is wrong with this coding. while this select is perfectly working n sql plus.
regards
anwer
|
|
|
Re: ip address in form [message #288030 is a reply to message #288020] |
Fri, 14 December 2007 06:09 |
ThomasG
Messages: 3212 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
SYS_CONTEXT doesn't seem to work in Forms.
A workaround is to create a function in the database that returns the IP, and then use that.
|
|
|
Re: ip address in form [message #288565 is a reply to message #288020] |
Tue, 18 December 2007 00:45 |
sirfkashif
Messages: 70 Registered: September 2007 Location: Rawalpindi
|
Member |
|
|
salam anwar,
1) first make a database function
CREATE OR REPLACE FUNCTION RETURN_IP_ADDRESS
RETURN VARCHAR2
IS
IP_ADDRESS_V VARCHAR2(15);
BEGIN
SELECT SYS_CONTEXT('USERENV','IP_ADDRESS')
INTO IP_ADDRESS_V
FROM DUAL;
RETURN(IP_ADDRESS_V);
END;
2) then in ur pl code do this
ur_pl_variable := return_ip_address;
where ur_pl_variable is ur pl variable
3) done
|
|
|
|