Home » Developer & Programmer » Forms » get client ip address when initializing forms (Forms 10g)
get client ip address when initializing forms [message #462564] Fri, 25 June 2010 00:30 Go to next message
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 #462569 is a reply to message #462564] Fri, 25 June 2010 00:57 Go to previous messageGo to next message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
select nvl(sys_context('userenv','IP_ADDRESS'),
           utl_inaddr.get_host_address(sys_context('userenv','TERMINAL')))
         ip_address
from dual
/

Regards
Michel
Re: get client ip address [message #462573 is a reply to message #462569] Fri, 25 June 2010 01:07 Go to previous messageGo to next message
havok
Messages: 36
Registered: February 2010
Member
Thanks!
It is compiled. But get this error:
FRM-40735: PRE-FORM trigger raised unhandled exception ORA-24247
Re: get client ip address [message #462574 is a reply to message #462573] Fri, 25 June 2010 01:15 Go to previous messageGo to next message
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 #465145 is a reply to message #462574] Mon, 12 July 2010 22:22 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Sorry that I have been so long in replying. Have you solved your problem?

Looking in "Oracle® Database, PL/SQL Packages and Types Reference, 11g Release 1 (11.1.), B28419-03"
Table 2091 Exception - Internet Address Package
Number    Exception             Description
ORA-24247 NETWORK_ACCESS_DENIED Access to network is denied.
ORA-29257 UNKNOWN_HOST          The host is unknown.

David
Re: get client ip address [message #465147 is a reply to message #465145] Mon, 12 July 2010 22:30 Go to previous messageGo to next message
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:12
Do 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 #465148 is a reply to message #465147] Mon, 12 July 2010 22:33 Go to previous messageGo to next message
havok
Messages: 36
Registered: February 2010
Member
But now i trying to get remote ip address or last proxy
http://www.orafaq.com/forum/t/159633/150363/

[Updated on: Mon, 12 July 2010 22:38]

Report message to a moderator

Re: get client ip address [message #465232 is a reply to message #465148] Tue, 13 July 2010 04:24 Go to previous messageGo to next message
ranamirfan
Messages: 535
Registered: January 2006
Location: Pakistan / Saudi Arabia
Senior Member

Dear 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.


Regards,

Irfan
Re: get client ip address [message #465267 is a reply to message #465232] Tue, 13 July 2010 06:04 Go to previous messageGo to next message
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 #465271 is a reply to message #465267] Tue, 13 July 2010 06:12 Go to previous messageGo to next message
ramoradba
Messages: 2456
Registered: January 2009
Location: AndhraPradesh,Hyderabad,I...
Senior Member
Please read Orafaq forum guidelines before posting.
Next time please format your post using [code] [/code] tags
sriram

[Updated on: Tue, 13 July 2010 06:12]

Report message to a moderator

Re: get client ip address [message #465273 is a reply to message #465232] Tue, 13 July 2010 06:17 Go to previous messageGo to next message
havok
Messages: 36
Registered: February 2010
Member
ranamirfan wrote on Tue, 13 July 2010 04:24
Dear 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
 fake_timer TIMER; 
; 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 #465277 is a reply to message #465273] Tue, 13 July 2010 06:44 Go to previous messageGo to next message
ranamirfan
Messages: 535
Registered: January 2006
Location: Pakistan / Saudi Arabia
Senior Member

Dear Havok,

Thank you very much for prompt reply.I m using Forms11g.
Please see below pic.


/forum/fa/8006/0/


Kindly Explain again this portion.

/*
WHEN-TIMER-EXPIRED code

*/

Regards,

Irfan
  • Attachment: webutil.JPG
    (Size: 31.59KB, Downloaded 9323 times)
Re: get client ip address [message #465293 is a reply to message #465273] Tue, 13 July 2010 07:47 Go to previous messageGo to next message
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 #465298 is a reply to message #465293] Tue, 13 July 2010 08:05 Go to previous messageGo to next message
ranamirfan
Messages: 535
Registered: January 2006
Location: Pakistan / Saudi Arabia
Senior Member

Dear Mr.Hossain.

Kindly let me know which trigger I used for this code.

<< WHEN-NEW-FORM-INSTANCE >>

/*

Code

*/


Also explain
Exec_Sql.Column_value(cursorID, 1, :Block5.Cur_Code);


global.ip := ::Block5.Cur_Code;



Regards,

Irfan
Re: get client ip address [message #465301 is a reply to message #465298] Tue, 13 July 2010 08:16 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Yes, why are you using dynamic SQL for this?
Re: get client ip address [message #465307 is a reply to message #465298] Tue, 13 July 2010 09:20 Go to previous messageGo to next message
mehediu
Messages: 46
Registered: February 2010
Location: Dhaka
Member

yes you can use this code in the trigger
<<WHEN-NEW-FORM-INSTANCE>>
and set the value in a global variable and you will able to use this variable whole over the form and its child form.


Exec_Sql.Column_value(cursorID, 1, :global.ip_address);
it will set the 1st cursor value in :global.ip_address.

thanking you
md. mehedi hossain
Re: get client ip address [message #465309 is a reply to message #465307] Tue, 13 July 2010 09:23 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Again - why dynamic sql, what's wrong with static sql?
Re: get client ip address [message #465310 is a reply to message #465301] Tue, 13 July 2010 09:24 Go to previous messageGo to next message
mehediu
Messages: 46
Registered: February 2010
Location: Dhaka
Member

Because the code
<<
select nvl(sys_context('userenv','IP_ADDRESS'),
utl_inaddr.get_host_address(sys_context('userenv','TERMINAL')))
ip_address
from dual;
>>

is not work in form developer 6i as far i know that's why i use dynamic query.


Regards
Md. Mehedi Hossain
Re: get client ip address [message #465313 is a reply to message #465310] Tue, 13 July 2010 09:38 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Fair enough.
Re: get client ip address [message #465314 is a reply to message #465313] Tue, 13 July 2010 09:53 Go to previous messageGo to next message
ramoradba
Messages: 2456
Registered: January 2009
Location: AndhraPradesh,Hyderabad,I...
Senior Member
@mehediu
Quote:
Please read Orafaq forum guidelines before posting.
Next time please format your post using [code] [/code] tags
sriram
[Updated on: Tue, 13 July 2010 16:42]



sriram

[Updated on: Tue, 13 July 2010 10:02]

Report message to a moderator

Re: get client ip address [message #465361 is a reply to message #465314] Tue, 13 July 2010 14:10 Go to previous messageGo to next message
Littlefoot
Messages: 21808
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 Go to previous messageGo to next message
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

Re: get client ip address [message #465381 is a reply to message #465376] Tue, 13 July 2010 23:15 Go to previous messageGo to next message
mehediu
Messages: 46
Registered: February 2010
Location: Dhaka
Member

Hi,

I think if you want to use the webutil_clientinfo.get_ip_address
method u need to instal webutil package and some jar files . without this i think it will not work.


Regards
Md. Mehedi Hossain
Re: get client ip address [message #465403 is a reply to message #465381] Wed, 14 July 2010 01:42 Go to previous messageGo to next message
ranamirfan
Messages: 535
Registered: January 2006
Location: Pakistan / Saudi Arabia
Senior Member

Dear Havok,

Thanks for your help.

I thought you can not seen my last message carefully which I send you .As I already told you I m using forms 11g.

Identifier 'WEBUTIL_CLIENTINFO.GET_IP_ADDRESS' must be declared

Kindly see it again below error message.


/forum/fa/8009/0/


Regards,

Irfan
  • Attachment: webutil.JPG
    (Size: 31.59KB, Downloaded 9115 times)
Re: get client ip address [message #465407 is a reply to message #465403] Wed, 14 July 2010 01:48 Go to previous messageGo to next message
havok
Messages: 36
Registered: February 2010
Member
Oh, you have not installed webutil. Find information on how to install it. It is important libraries. How do I install, I can not help you.
Re: get client ip address [message #465410 is a reply to message #465407] Wed, 14 July 2010 01:55 Go to previous messageGo to next message
ranamirfan
Messages: 535
Registered: January 2006
Location: Pakistan / Saudi Arabia
Senior Member

From where I download this webutil ?
'WEBUTIL_CLIENTINFO.GET_IP_ADDRESS'
Re: get client ip address [message #465448 is a reply to message #465410] Wed, 14 July 2010 03:29 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Search your Developer tree for 'webutil'.

David
Re: get client ip address [message #465491 is a reply to message #465448] Wed, 14 July 2010 06:19 Go to previous messageGo to next message
ranamirfan
Messages: 535
Registered: January 2006
Location: Pakistan / Saudi Arabia
Senior Member

Dear Mr.David,

After Configured & attached the Webutil Librariy & I can't get required result.My Form run successfully and can't show any thing.

Please see my below code.


WHEN-NEW-FORM-INSTANCE
Declare
    fake_timer TIMER;     
Begin
    fake_timer:= Create_Timer('WEBUTIL',10,NO_REPEAT);
End;


Then

WHEN-TIMER-EXPIRED
    declare
    which_timer VARCHAR2(50);       
begin
    which_timer := GET_APPLICATION_PROPERTY(TIMER_NAME);
    if which_timer = 'WEBUTIL' then
       message('Client IP Address.. '||webutil_clientinfo.get_ip_address);
       message('Client IP Address.. '||webutil_clientinfo.get_ip_address);
            
    end if;



Please advise me.

Regards,

Irfan



Re: get client ip address [message #465626 is a reply to message #465491] Thu, 15 July 2010 00:55 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Put 'message;pause;' pairs nearly everywhere and determine which part of the code is being navigated and which is not being navigated.

You can also use the 'message' to display the name of the timer that has fired.

David
Re: get client ip address [message #465635 is a reply to message #465626] Thu, 15 July 2010 01:04 Go to previous messageGo to next message
havok
Messages: 36
Registered: February 2010
Member
Webutil shows the correct address if you call in the trigger button is pressed?
Re: get client ip address [message #465639 is a reply to message #465635] Thu, 15 July 2010 01:09 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Does this mean that you have a working solution and have solved your problem?

David
Previous Topic: Populate record in Data Block
Next Topic: Select photo (BLOB) data into Developer6i Image Item
Goto Forum:
  


Current Time: Fri Apr 26 16:14:04 CDT 2024