Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Oracle UTL_I18N

Oracle Database Tips by Donald Burleson

Advanced Oracle Utilities: The Definitive Reference by Rampant TechPress is written by top Oracle database experts (Bert Scalzo, Donald Burleson, and Steve Callan).  The following is an excerpt from the book.

This oddly named package is based on internationalization. Keeping the leading I and trailing N, and removing what is in-between, 18 characters are eliminated. Internationalization is then abbreviated as I18N, a small example of Oracle humor.

 

What is the package used for? For the most part, it is used to perform translations or lookups based on the developer's locale or input. For example, one can list out time zones.

 

DECLARE

   x   UTL_HTTP.HTML_PIECES;

   len PLS_INTEGER;

BEGIN

   x := UTL_HTTP.REQUEST_PIECES('http://www.oracle.com/', 100);

   DBMS_OUTPUT.PUT_LINE(x.count || ' pieces were retrieved.');

   DBMS_OUTPUT.PUT_LINE('with total length ');

   IF x.count < 1 THEN

      DBMS_OUTPUT.PUT_LINE('0');

  ELSE

   len := 0;

   FOR i in 1..x.count LOOP

      len := len + length(x(i));

   END LOOP;

   DBMS_OUTPUT.PUT_LINE(len);

  END IF;

END;

/

 

Count = 119

Pacific/Pago_Pago

Pacific/Honolulu

America/Anchorage

America/Vancouver

America/Los_Angeles

America/Tijuana

America/Edmonton

continues…

 

How about all of the local time zones based on America?

 

DECLARE

 retval utl_i18n.string_array;

 cnt    PLS_INTEGER;

BEGIN

  retval := utl_i18n.get_local_time_zones('AMERICA');

  dbms_output.put('Count = ');

  dbms_output.put_line(retval.LAST-retval.FIRST+1);

  cnt := retval.FIRST;

 

  WHILE cnt IS NOT NULL LOOP

    dbms_output.put_line(retval(cnt));

    cnt := retval.NEXT(cnt);

  END LOOP;

END;

/

Count = 8

America/New_York

America/Indianapolis

America/Chicago

America/Denver

America/Phoenix

America/Los_Angeles

America/Anchorage

Pacific/Honolulu

 

PL/SQL procedure successfully completed.

 

Experiment with the subprograms and see what gets returned.

UTL_INADDR

This simple package can be used to get the host address and host name, both remote and local. An example of the subprograms shows the following with respect to a local host.

 

BEGIN

  DBMS_OUTPUT.PUT_LINE(UTL_INADDR.GET_HOST_NAME); 

  -- get local host name

  DBMS_OUTPUT.PUT_LINE(UTL_INADDR.GET_HOST_ADDRESS); 

  -- get local IP addr

END;

/

T42

10.10.10.10

 

PL/SQL procedure successfully completed.

 

The name of the computer running this code is T42, and the IP address, at least one of them, is 10.10.10.10, which may be recognized as a dummy address used for the Microsoft loopback adapter.

 

What is the host name where dba-oracle.com is hosted? The nslookup command returns an IP address of 65.109.93.192. Use this IP address and see what the host name is.

 

select

  UTL_INADDR.GET_HOST_NAME

  ('65.109.93.192')

from

  dual;

 

UTL_INADDR.GET_HOST_NAME('65.109.93.192')

-----------------------------------------

dba-oracle.com

 

One of Google's IP addresses is used in the following query just to show that the hostname is not the obvious name as in the previous example.

 

select

  UTL_INADDR.GET_HOST_NAME

  ('64.233.167.99')

from

  dual;

 

UTL_INADDR.GET_HOST_NAME('64.233.167.99')

-----------------------------------------

py-in-f99.google.com

UTL_LMS

The UTL_LMS package is handy when it comes to translating Oracle messages into another language. People who moderate on an Oracle-related forum have undoubtedly run across someone who posts a topic and left the error message in the poster's native tongue, which invariably is not English.

 

With the right adjustment of the language setting, error messages can be translated.

 

DECLARE

  s varchar2(200);

  i pls_integer;

BEGIN

   i:=utl_lms.get_message(601, 'rdbms', 'oci', 'french', s);

   dbms_output.put_line('OCI--00601 is: '||s);

END;

/

 

OCI—00601 is: Echec du processus de nettoyage.

 

The input parameters are errnum, product, facility, language and message.


 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.