get client ip address when initializing forms [message #462564] |
Fri, 25 June 2010 00:30 |
havok
Messages: 36 Registered: February 2010
|
Member |
|
|
How to get the client machine IP in Forms 10g without using webutil?
I know the function Webutil_clientinfo.get_ip_address. But Webutil is not working in when new form instance. And I need get client ip address in trigger PRE-FORM.
sys_context('userenv', 'IP_ADDRESS') return address of server, not client.
OR
How to make the trigger WHEN-CUSTOM-ITEM-EVENT in Webutil starts before triggers "WHEN-NEW-FORM-INSTANCE" and "PRE-FORM" ?? To use webutil_clientinfo.get_ip_address
[Updated on: Fri, 25 June 2010 00:49] Report message to a moderator
|
|
|
|
|
Re: get client ip address [message #462574 is a reply to message #462573] |
Fri, 25 June 2010 01:15 |
havok
Messages: 36 Registered: February 2010
|
Member |
|
|
I can to writte as:
v_ip: = NVL (SYS_CONTEXT ('USERENV', 'IP_ADDRESS'), SYS_CONTEXT ('USERENV', 'TERMINAL'));
BUT, it returns the server address! And I need get client ip address.
This
v_ip_from_inaddr := utl_inaddr.get_host_address(sys_context('userenv','TERMINAL')); get error as in previous post
[Updated on: Fri, 25 June 2010 01:27] Report message to a moderator
|
|
|
|
Re: get client ip address [message #465147 is a reply to message #465145] |
Mon, 12 July 2010 22:30 |
havok
Messages: 36 Registered: February 2010
|
Member |
|
|
Yes! I use webutil in timer. Found this solution:
alan.m.bulmer@ic24.net wrote on Wed, 27 August 2008 03:12Do not try to use these webutil procedures in forms during either PRE-FORM or WHEN-NEW-FORM-INSTANCE. If you do need this information at this point then create a TIMER (1 second should do it) in WHEN-NEW-FORM-INSTANCE, then in the trigger WHEN-TIMER-EXPIRED make your call to the webutil procedure and all should be ok,
|
|
|
|
|
Re: get client ip address [message #465267 is a reply to message #465232] |
Tue, 13 July 2010 06:04 |
mehediu
Messages: 46 Registered: February 2010 Location: Dhaka
|
Member |
|
|
u can use this code , may be it work.
------------------------------------------
DECLARE
connection_id EXEC_SQL.CONNTYPE;
bIsConnected BOOLEAN;
cursorID EXEC_SQL.CURSTYPE;
sqlstr VARCHAR2(1000);
nIgn PLS_INTEGER;
nRows PLS_INTEGER := 0;
nTimes PLS_INTEGER := 0;
mynum NUMBER;
mynum2 varchar2(10);
BEGIN
--
-- obtain the default connection and check that it is valid
--
connection_id := EXEC_SQL.DEFAULT_CONNECTION;
bIsConnected := EXEC_SQL.IS_CONNECTED;
IF bIsConnected = FALSE THEN
TEXT_IO.PUT_LINE('No primary connection. Please connect before retrying.');
RETURN;
END IF;
cursorID := EXEC_SQL.OPEN_CURSOR;
sqlstr := 'select nvl(sys_context(''userenv'',''IP_ADDRESS''),
utl_inaddr.get_host_address(sys_context(''userenv'',''TERMINAL''))) ip_address from dual';
EXEC_SQL.PARSE(cursorID, sqlstr, exec_sql.V7);
EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 1, mynum2, 30);
nIgn := EXEC_SQL.EXECUTE(cursorID);
IF (EXEC_SQL.FETCH_ROWS(cursorID) > 0) THEN
EXEC_SQL.COLUMN_VALUE(cursorID, 1, :BLOCK5.CUR_CODE);
next_record;
ELSE
null;
END IF;
EXEC_SQL.CLOSE_CURSOR(cursorID);
EXEC_SQL.CLOSE_CONNECTION;
END;
-------------------------
regards
mehedi hossain
[Updated on: Tue, 13 July 2010 06:09] by Moderator Report message to a moderator
|
|
|
|
Re: get client ip address [message #465273 is a reply to message #465232] |
Tue, 13 July 2010 06:17 |
havok
Messages: 36 Registered: February 2010
|
Member |
|
|
ranamirfan wrote on Tue, 13 July 2010 04:24Dear Havok,
I can not used before Webutil funtion in Forms.
Can you tell me step by step procedure for How to get the client machine IP in Forms 10g using Webutil.
Thanks in Advance for help.
My problem was that webutil does not work in triggers Pre-form, when-new-form-instans. Webutil works AFTER trigger when-new-form-instans.
Therefore, the algorithm for solving this problem is:
in the trigger WHEN-NEW-FORM-INSTANCE to create a timer. In declare ; then in the same trigger
fake_timer: = CREATE_TIMER ('WEBUTIL', 10, REPEAT);
Next, in trigger WHEN-TIMER-EXPIRED code like this:
if which_timer = 'WEBUTIL' then
.....
v_ip: = webutil_clientinfo.get_ip_address;
And it works
[Updated on: Tue, 13 July 2010 06:19] Report message to a moderator
|
|
|
|
Re: get client ip address [message #465293 is a reply to message #465273] |
Tue, 13 July 2010 07:47 |
mehediu
Messages: 46 Registered: February 2010 Location: Dhaka
|
Member |
|
|
you dot need Webutil.
you just use the following code and you will get the IP address in the global variable :global.ip.
-----------------------
DECLARE
connection_id EXEC_SQL.CONNTYPE;
bIsConnected BOOLEAN;
cursorID EXEC_SQL.CURSTYPE;
sqlstr VARCHAR2(1000);
nIgn PLS_INTEGER;
nRows PLS_INTEGER := 0;
nTimes PLS_INTEGER := 0;
mynum NUMBER;
mynum2 varchar2(10);
BEGIN
--
-- obtain the default connection and check that it is valid
--
connection_id := EXEC_SQL.DEFAULT_CONNECTION;
bIsConnected := EXEC_SQL.IS_CONNECTED;
IF bIsConnected = FALSE THEN
TEXT_IO.PUT_LINE('No primary connection. Please connect before retrying.');
RETURN;
END IF;
cursorID := EXEC_SQL.OPEN_CURSOR;
sqlstr := 'select nvl(sys_context(''userenv'',''IP_ADDRESS''),
utl_inaddr.get_host_address(sys_context(''userenv'',''TERMINAL''))) ip_address from dual';
EXEC_SQL.PARSE(cursorID, sqlstr, exec_sql.V7);
EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 1, mynum2, 30);
nIgn := EXEC_SQL.EXECUTE(cursorID);
IF (EXEC_SQL.FETCH_ROWS(cursorID) > 0) THEN
EXEC_SQL.COLUMN_VALUE(cursorID, 1, :BLOCK5.CUR_CODE);
--next_record;
ELSE
null;
END IF;
:global.ip := :BLOCK5.CUR_CODE;
EXEC_SQL.CLOSE_CURSOR(cursorID);
EXEC_SQL.CLOSE_CONNECTION;
message(:global.ip);
message(:global.ip);
END;
----------------
regards
mehedi hossain
|
|
|
|
|
|
|
|
|
|
Re: get client ip address [message #465361 is a reply to message #465314] |
Tue, 13 July 2010 14:10 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
What, a man had provided a nice, working solution. Explained how to do that. Explained why he did that as he did.
And now here you come, pinpricking with a Forum Guide (sometimes I'm really sorry for creating it the way it is). Don't you see that he is a new OraFAQ Forum user? Give him a break, will you? People need some time to learn the "rules", anywhere they come. But no - let's harass new members and scare them away. So what, new ones (fresh meat) will come anyway!
As all of your contribution to the discussion was that silly "format the code and follow the rules", in my opinion you shouldn't even stop and waste your precious time. Perhaps you are perfect - some of us aren't. So please, refrain from such comments (if they are all you have (know) to say).
|
|
|
Re: get client ip address [message #465376 is a reply to message #465277] |
Tue, 13 July 2010 21:14 |
havok
Messages: 36 Registered: February 2010
|
Member |
|
|
ranamirfan wrote on Tue, 13 July 2010 06:44
Kindly Explain again this portion.
/*
WHEN-TIMER-EXPIRED code
*/
Regards,
Irfan
WHEN-TIMER-EXPIRED:
declare
which_timer VARCHAR2(50);
...
begin
which_timer := GET_APPLICATION_PROPERTY (TIMER_NAME);
if which_timer = 'WEBUTIL' then
v_ip := webutil_clientinfo.get_ip_address;
...
end if;
...
WHEN-NEW-FORM-INSTANCE:
declare
fake_timer TIMER;
...
begin
fake_timer:= CREATE_TIMER('WEBUTIL',100,NO_REPEAT);
...
would be better if the rest of the code from the WHEN-NEW-FORM-INSTANCE trigger to move to the WHEN-TIMER-EXPIRED (to "if which_timer = 'WEBUTIL' then")
[Updated on: Tue, 13 July 2010 21:23] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|