Oracle ApEx如何获取PC本地IP地址

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2218886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 19:58:37  来源:igfitidea点击:

How to obtain local IP address of PC within Oracle ApEx

oracleplsqloracle-apex

提问by tonyf

I need a means of obtaining the local IP Address (Windows box listed in ipconfig command info) from within Oracle ApEx.

我需要一种从 Oracle ApEx 中获取本地 IP 地址(ipconfig 命令信息中列出的 Windows 框)的方法。

Is this possible? I have tried both owa_util.get_cgi_env('REMOTE_ADDR')as well as sys_context( 'userenv', 'ip_address' )

这可能吗?我曾经尝试都owa_util.get_cgi_env('REMOTE_ADDR')以及sys_context( 'userenv', 'ip_address' )

Just can't seem to get my local PC IP address within Oracle ApEx.

只是似乎无法在 Oracle ApEx 中获取我的本地 PC IP 地址。

Any ideas?

有任何想法吗?

采纳答案by FerranB

To obtain the Oracle ClientIP address you have to use the one you suggested::

要获取Oracle 客户端IP 地址,您必须使用您建议的地址:

select sys_context('userenv','ip_address') 
  from dual;

To obtain the Oracle ServerIP address you can use:

要获取Oracle ServerIP 地址,您可以使用:

select utl_inaddr.get_host_address(sys_context('userenv','server_host')) 
  from dual;

UPDATE (from comment):If you are looking for the application server IP, nor client nor server. Right? This cannot be obtained by oracle. This is like asking oracle the web server IP. As Oracle Appex is 100% PLSQL you cannot obtain this information.

更新(来自评论):如果您正在寻找应用程序服务器 IP,则既不是客户端也不是服务器。对?这是oracle无法获得的。这就像向 oracle 询问 Web 服务器 IP。由于 Oracle Appex 是 100% PLSQL,您无法获得此信息。

回答by Gary Myers

Bear in mind what your PC tells you, with ipconfig, may be a local network IP address. My home PC is assigned its address by the local router as 192.168.0.10 which would be same as ten thousand other PCs on networks around the world.

请记住您的 PC 告诉您的信息,使用 ipconfig,可能是本地网络 IP 地址。我的家用 PC 由本地路由器分配的地址为 192.168.0.10,这与世界各地网络上的一万台 PC 相同。

That said, see if thisor thisis any help.

也就是说,看看这个这个是否有帮助。