
National Language Support (NLS) is a feature that enables Oracle database users to interact with the database in their native language. It also enables applications written in different national languages to interact with different NLS configurations.
Oracle's NLS architecture has two main components: language-independent functions used to provide generic language features, and language-dependent data used to work with features for a specific language. Oracle Server uses several encoding schemes to enable NLS capability. In essence, letters typed from a keyboard are displayed onscreen with character encoding. The encoding schemes commonly used by Oracle8 Server are categorized into single-byte 7-bit (7-bit ASCII), single-byte 8-bit (ISO 8859/1), varying-width multi-byte (for Chinese and other Asian languages), and fixed-width multi-byte (a subset of varying-width multi-byte). For more information on encoding schemes and restrictions on character sets, review the Oracle8 Server Reference in the Oracle documentation set.
Oracle8 has a new datatype, NCHAR, which facilitates the existence of two character sets in one database instance. Oracle8 also adds support for fixed-length native Unicode 2.0 and Chinese language support.
Setting the database character set is something you should do before creating a database instance. All database character data is stored in the character set specified during database creation. Although you may be able to change the character set of objects created later, characters in the data dictionary are stored in the character set used during creation and can't be changed later. The database character set is used for the following items:
The database set must be derived from 7-bit ASCII or EDCDIC character sets. The database character set can be a varying-width multi-byte character set.
The National Character set is used for handling data stored in the NCHAR, NCLOB, and NVARCHAR2 datatypes. You can use a fixed-width or a varying-width multi-byte character set for the National Character Set.
| Some performance improves with the National Character Set |
You might see some performance gain in string operations when you choose a fixed-width character set for the National Character Set versus a varying width character set. Smaller width (varying width) character sets are more efficient in reducing data storage capacity. |
You can set NLS parameters as default values for the server. The client software can alter the server default values, if desired. The following parameters in the initialization file (INITSID.ORA) set the default NLS values for the server:
NLS_LANGUAGE ="US7ASCII"
NLS_LANGUAGE="GERMAN"
NLS_TERRITORY="GERMANY"
NLS_CALENDAR="Gregorian"
NLS_CALENDAR='Thai Buddha"
NLS_DATE_FORMAT = "DD/MM/YYYY"
NLS_SORT = Greek
Most NLS parameters can be set in an interactive session and as environment variables on UNIX and Windows NT. You can set the following NLS variables as initialization parameters, environment variables, and ALTER SESSION parameters:
| NLS_CURRENCY | NLS_ISO_CURRENCY |
| NLS_DATE_FORMAT | NLS_NUMERIC_CHARACTERS |
| NLS_DATE_LANGUAGE | NLS_SORT |
| Setting NLS values interactively with the ALTER SESSION command |
If you want to set a parameter such as NLS_DATE_LANGUAGE to Spanish by using an interactive ALTER SESSION command, the syntax would be ALTER SESSION SET NLS_DATE_LANGUAGE="SPANISH". For this particular session, the ALTER SESSION command will override the default value of NLS_DATE_LANGUAGE. |
You can set NLS_LANGUAGE and NLS_TERRITORY as initialization parameters and ALTER SESSION parameters but not as environment variables.
The NLS variables that you can set only as environment variables are
| NLS_CREDIT | NLS_LIST_SEPERATOR |
| NLS_DEBIT | NLS_MONETARY_CHARACTERS |
| NLS_DISPLAY | NLS_NCHAR |
| NLS_LANG |
You can use NLS parameters in SQL statements that depend on NLS conventions. Applications using these SQL functions can explicitly call the functions independently of the environment variables or session parameters:
| Using environment variables modify NLS values |
If you want to set the value of a variable such as NLS_CREDIT by using UNIX environment variables, the syntax would be setenv NLS_CREDIT="CR". This would append the symbol CR in financial statements and reports, wherever applicable. |
For more details, refer to the Oracle8 Server Reference in the Oracle8 documentation set.
In today's distributed architecture and global economies, organizations have database servers all over the world and need to exchange information in a timely and efficient manner. Oracle Replication is widely used to provide data access to different Oracle databases, as well as provide redundancy in the case of disaster. Replication is also used to distribute processing loads in distributed systems and give mobile workers the capability to work with the master database site.
| New replication features in Oracle8 |
Oracle8 provides several new features that enrich Replication functionality: parallel propagation of deferred transactions, internalized replication triggers, reduced data propagation, LOB (large binary object) support, data subsetting based on subqueries, and primary key snapshots. The number of transactions to be replicated as well as the mechanism have been improved over Oracle7. Oracle8 sends row-level changes over the network to the replicated site, also optimizing bandwidth requirements. Improvements in Replication Manager 1.4 also make it easier to design and manage a replicated environment. |
Oracle provides two forms of replication: basic and advanced. In the most elementary form of replication-basic-replicated sites have read-only access to data being maintained at the master site. Advanced replication gives replicated sites full read/write access to data at the master site.
You can implement Oracle advanced replication by using two basic configurations or a combination of the two:
Replication objects, groups, sites, and catalogs are the basic components of an advanced replication configuration. Let's take a quick look at their definitions:
An advanced replication configuration requires certain special user accounts: replication administrator, replication propagator, and replication receivers. Each site-snapshot or master-requires a replication administrator. The replication administrator, propagator, and receiver can be the same Oracle account but have to be set up individually.
Oracle8 uses a combination of internal triggers, deferred transactions, and job queues to propagate data and object changes between replicated sites. The internal triggers capture the changes to be propagated and execute them on replicated sites by using remote procedure calls. These remote procedure calls are stored in deferred transaction queues for later propagation. The actual propagation process is managed by using job queues and deferred transactions.
A local job queue is maintained on each database server participating in the replicated configuration containing information about the PL/SQL procedure, the schedule to run the job, and so on. These jobs will probably include but not be restricted to pushing deferred transactions to master sites, purging applied transactions from deferred transaction queues, and refreshing update snapshot groups.
| Use APIs to track advanced replication |
Oracle8 also provides a set of application program interfaces (APIs) to track and facilitate advanced replication. Some of these packages are DBMS_DEFER_QUERY,DBMS_DEFER,DBMS_OFFLINE, DBMS_REPCAT, and DBMS_SNAPSHOT. These packages, in combination with the replication data-dictionary views, are used to find out information about a transaction. For a complete listing of these views and packages, refer to Oracle8Replication, which is part of the documentation set published by Oracle Corporation. |
Oracle8 provides data-dictionary views that contain detailed information about deferred transactions. These views are used to administer an advanced replication configuration. Some views are DEFCALL, DEFCALL_DEST, DEFDEFAULTDEST, DEFERRCOUNT, DEFERR, and DEFSCHEDULE.
Transactions that can't be completed are rolled back at the destination site and are logged in the DEFERROR view, which stores the identity number of the transaction that couldn't be applied. The DEFCALL view lists each remote procedure call associated with a particular deferred transaction and the number of arguments to the procedure. However, to know the value of the argument, you have to know the type of argument. This is obtained by using the GET_ARG_TYPE function of the DBMS_DEFER_QUERY package:
![]() | Argument number of the remote call |
![]() | Identity number of the deferred transaction; get its value from DEFERROR view |
For example, in a SQL*Plus session, you would call this package as follows:
![]() | Numeric variable declared in SQL*Plus session; you can call it anything |
![]() | ID number corresponding remote call |
This function would return a numeric value that corresponds to a datatype: 1 represents VARCHAR2, 2 represents NUMBER, 11 represents ROWID, 12 represents DATE, 23 represents RAW, and 96 represents CHAR. When you know the value of the returned number and hence the corresponding datatype, you can use another function, GET_VARCHAR2_ARG (if the return value was 1 representing a VARCHAR2), to get the actual value of the datatype.
The process of building a replicated architecture involves several steps that involve planning and making decisions regarding the replicated configuration. At this stage, you define the schemas to be replicated, including tables, packages, and triggers. You also decide the number of sites at which you want your data replicated.
For organizational efficiency and for ease of administration, it's a good idea to group objects into replication groups. With Oracle8, you can turn off replication for replicated groups without affecting the other groups. This helps sometimes when you want to do maintenance on certain schemas and don't want to stop the rest of the database to stop replication.
You also can decide if you want snapshot replication or full multimaster replication or a combination of both. On today's systems, a lot of static tables or metadata tables are meant for lookup only and don't change. You can decide not to replicate such static tables, at least when using Advanced Replication. When configuring snapshot replication, the additional components of the system are snapshot logs and refresh groups. Snapshot logs are created at each master site to support the necessary snapshots. Refresh groups are created at each snapshot site. At each snapshot site, you also create snapshot groups that correspond to master group objects.
Finally, depending on the need for "fresh or refreshed" data at replicated sites, you might want to decide on an interval at which you want the replicated data to go across to the replicated site. As a DBA, you'll have to go through some trial and error to get the exact configuration you want for your shop, depending on your business needs, nature and amount of data, money you can invest in hardware, and so forth.
Oracle Replication Manager is a GUI tool that helps you build and track a replicated schema. This tool provides graphical shortcuts to several API calls that are normally made from the server, and displays information in a easy-to-understand graphical fashion.
| This tool is available only in Windows |
You can install Replication Manager on a PC that acts as client to an Oracle server, and most configuration and management can be done from within Replication Manager. Thus, the platform of the database server doesn't matter, as long you have a PC running Windows. If you still want to configure and track replication from a UNIX server or a workstation, you have to write/modify your own scripts. |
Replication Manager comes with replication wizards that help configure a replication schema. With Replication Manager, you can also connect to a master site and create master replication groups. Replication Manager will also create the Replication Administrator, Propagator, and Receiver accounts. Finally, you can use Replication Manager to create the database links that facilitate communications between sites. You can configure and create multimaster as well as snapshot replication sites with this tool.
To start Replication Manager, from the Start menu choose Programs, Oracle Replication Manager. Click the icon for Oracle Replication Manager. Figure 26.1 shows the startup window of the Replication Manager.
Click the Create button on the right. In the Create DB Connection dialog box, you may or may not want to keep the two check boxes checked (see Figure 26.2), depending on how secure your PC and office environment is.
Set up a master site with the Replication Manager Setup Wizard
| What's in a site name? |
The site name corresponds to a service or Net8 alias with which you can connect to the database. For more information on Net8 aliases, refer to Chapter 24, "Configuring and Using Net8 Features." |
The process of managing replicated sites is more complex than administering single sites. The issues are different for each configuration, whether you're dealing with multimaster, snapshot, or hybrid. Let's take a quick look at several tasks that database and replication administrators must perform for smooth operation of a replicated configuration:
| Defining quiescing |
Although the term quiescing isn't recognized in the dictionary, it's related to the word "quiescent," which means quiet, still, inactive. In Oracle, quiescing refers to the process of suspending replication activity between sites. This is normally done before performing administration tasks on master sites. |
| Deciding a conflict resolution mechanism for an advanced replication architecture |
Designers can use a combination of several conflict-resolution techniques, depending on the business and configuration needs of their sites: minimum and maximum update, earliest and latest time-stamp update, additive and average update, priority group and site priority update, overwrite and discard update, append site name/sequence uniqueness, and discard uniqueness. A good strategy for a replication designer would be to look at individual columns and groups to decide the nature of updates, and then design the conflict-resolution mechanism. |
Spatial data refers to location characteristics of objects as they relate to each other in real-world two-dimensional relationships. A map is an example of spatial data. Geographic information systems (GIS) that store spatial data would be likely users of Oracle's Spatial Data Cartridge, which provides a set of functions and procedures designed specifically for storing, retrieving, and analyzing spatial data. (For more detailed definitions of cartridges, see the later section "Oracle Web Server Cartridges.") Besides data from GIS systems, two-dimensional computer-aided design (CAD) drawings could be also stored as spatial data, because CAD drawings indicate the location of objects/parts (actually, primitives) in relation to each other.
In most CAD packages, data representation is done internally with primitive datatypes. A "primitive" is the most basic form of representation of an object. Different forms of geometry, such as arcs and circles, are created by using a combination of primitive datatypes. Oracle's Spatial Data Cartridge supports three basic type of primitives and geometries (all two-dimensional) generated by using a combination of these three types:
The Oracle Spatial Data Model essentially consists of elements, geometries, and layers arranged hierarchically. Elements make up geometries, which in turn make up layers:
Oracle's Spatial Data Cartridge uses four tables/views to store and index spatial data. These four tables make up a layer:
| Syntax for tables that make up layer definition for spatial data |
The syntax for these tables is layername_TABLE, where layername is the name of the layer and TABLE is either SDOLAYER,SDODIM,SDOGEOM, or SDOINDEX. A layer can be defined completely by using these four tables. |
| Spatial data indexing |
Spatial data uses a special index, HHCODE, for indexing data. HHCODEs are also called "tiles." Users can adjust the number of tiles that cover a surface. In a way, it represents the granularity of a data search. The finer the grain, the longer it would take to search the data. The technique of determining how many tiles cover a surface is called "tessellation." Tile size can be fixed or variable. |
| SDOLAYER | ||
| SDO_ORDCNT | Number | This column is the total count of ordinates per row present in the SDOGEOM table. |
| SDO_LEVEL | Number | This column maintains a count of number of times layername was tessellated during the index build stage. |
| SDODIM | ||
| SDO_DIMNUM | Number | This column keeps track of the dimension to which a row refers. The minimum value is 1. |
| SDO_LB | Number | This column is the lower bound (LB) of the ordinate in the relevant dimension. For example, on a X-Y coordinate system with a maximum X of 100 and minimum of -100, the LB would be -100. |
| SDO_UB | Number | This column represents the upper bound of the ordinate in the relevant dimension. For example, if the dimension were latitude, this value would be 90. |
| SDO_TOLERANCE | Number | This represents the tolerance associated with points in the data. This value must be greater than zero. SDO_TOLERANCE will vary for different types of spatial data for different dimensions. |
| SDO_DIMNAME | VARCHAR | This represents the name used for this dimension; it can be X/Y or latitude/longitude. |
| SDOGEOM | ||
| SDO_GID | Number | This column represents the geometric identifier (GID), a unique number that represents each geometrical object in a layer. |
| SDO_ESEQ | Number | This column represents the element sequence number. A geometrical object is comprised of primitive elements. This column lists each element in the geometry for that layer. |
| SDO_ETYPE | Number | This column represents the element type. For example, a POINT type has an ETYPE value of 1, a LINESTRING has a value of 2, and so on. |
| SDO_SEQ | Number | This column represents the sequence number of each row of data for the element. |
| SDO_X1 | Number | This column represents the X value of the first X coordinate. |
| SDO_Y1 | Number | This column represents the Y value of the first Y coordinate. |
| SDO_Xn and SDO_Yn | Number | These columns represent the X and Y values of the nth coordinate, respectively. |
| SDOINDEX | ||
| SDO_GID | Number | This column really acts as a foreign key to the SDOGEOM table. |
| SDO_CODE | RAW | Data representation is done in the form of tiles. This column contains the value of the bit interleaved ID of a tile that covers SDO_ID. |
| SDO_MAXCODE | RAW | This column is the SDO_CODE with an extra value one unit farther than the allowable maximum value of the index. Basically, it describes a logical tile. |
Spatial data must be treated differently as compared with conventional data, because the indexing and data-retrieval techniques are different. Spatial data can be entered into tables interactively from applications or by using SQL*Loader for mass/batch loads.
Spatial data is queried in essentially a two-step process. The first step, referred to as a "primary filter," uses algorithms to approximate search patterns to narrow down the search size. The output from the first filter is passed to the second stage (called the "secondary filter"). The secondary filter uses exact calculations of geometry to the smaller output of the primary filter to find a match.
Spatial data applications perform a spatial query when information contained in a bounding or a query window is requested. The query window calls the SDO_WINDOW package, which performs the data calculations.
A spatial join is the output of joining two tables (layers) with spatial operators. A spatial join would join two layers with the layername_SDOINDEX field. An example of a query that causes a spatial join could be a list of all road and railway intersections in town.
Oracle Web Application Server is a superset of a standard HTTP server, with extensions (cartridges) that integrate seamlessly with the Oracle server. Similar to Spatial Data Cartridges, the cartridges that ship with Oracle Web Server are functions and packages that act as extensions to the core database product of the Oracle database server. You can program cartridges in various programming languages, such as C++, C, Visual Basic, and Java.
| Reading current documentation for Oracle Web Server |
Because Oracle Web Application Server is evolving rapidly and has seen at least three version upgrades in the last two years, I recommend that you use the online documentation provided by Oracle Corporation along with the Web Application Server for configuring the cartridges and Web Request Broker because this area is evolving quickly. This section covers the basic principles of Oracle Web Application Server 3.0 and is meant as an introduction. You can refer to the online documentation for the most current configuration techniques. |
The Web Application Server comes in two versions: advanced and standard. The advanced version is a superset of the standard version. Some notable features present in the advanced version but not in the standard version are as follows:
The major components that are similar in the advanced and standard version are as follows:
Oracle Web Application Server 3.0 has been replaced by version 4.0, which is called Oracle Application Server. Oracle Application Server is designed to enable organizations to deploy and manage applications on a single server, rather than on hundreds or thousands of desktop PCs (the case in a two-tier architecture). Oracle Application Server 4.0 is designed to support all types of network clients, serving as a central point of access to any database, application, or legacy system.
All features of version 3.0 are available in 4.0, including backward compatibility with all cartridges. Version 4.0 also has several new cartridges, including new Oracle Call Interface (OCI) cartridge for native access to Oracle databases, an ODBC cartridge for access to any third-party database, and a new Rdb cartridge for access to Oracle Rdb database applications. A COBOL cartridge, made by Fujistu Corporation, enables access to COBOL applications. The AppBuilder wizard, made by Borland, provides designers with step-by-step help for designing Web applications.
This section explains major features of two commonly used cartridges: PL/SQL and the Java cartridge. To understand the functioning of the cartridges, you need to understand the architecture of the Web Server. The Oracle Web Application Server has three major components:
| Integrating Web Application Server with other major Web server listeners |
You can use Web servers from Netscape or Microsoft as the listener component if you don't want to use the listener that ships with the Web Server. The Oracle Web Application Server Installation Guide has information on configuring other major vendor listeners to use with the Web Application Server. |
Web Application Server comes bundled with several cartridges, of which the following are just some:
When the Web Application Server receives a request from a client, the listener component processes the request first and determines how it should handle the request. If the request is for a static file (a file that exists on a file system), the listener fetches the file from the operating system and sends it to the client. If the request is to execute a CGI (Common Gateway Interface) file/script, the listener executes the file and sends the results back to the client.
If the request is for a cartridge, the listener performs the following:
The PL/SQL Cartridge provides the environment for developing Web applications as PL/SQL procedures stored in an Oracle database server. (PL/SQL is Oracle Corporation's procedural language extension to SQL.) When you configure the PL/SQL Cartridge, you install packages that help generate HTML pages. These packages define procedures, functions, and datatypes you can use in your stored procedures. In each HTTP request for the PL/SQL Cartridge, the uniform resource locator (URL) specifies the PL/SQL agent (which contains connection information) and the name of the stored procedure to run. The URL can also contain values for any parameters required by the stored procedure.
Before you can use the PL/SQL Cartridge, you need to load the packages listed in this section into the database schemas from which you want to run the procedures. The packages define datatypes, functions, and procedures used by the cartridge, and you can use some of them in your Web application. The functions and procedures help you generate dynamic HTML pages that contain data retrieved from the database.
| The PL/SQL agent and the DAD |
Like the PL/SQL agent, a DAD is a named set of configuration values used for database access. It specifies information such as the database name or the SQL*Net/Net8 service name, the ORACLE_HOME directory, and NLS configuration information such as language, sort type, and date language. You can also specify username and password information in a DAD; if they aren't specified, the user will be prompted to enter a username and password when the URL is invoked. The PL/SQL agent specifies information such as which DAD to use, how much error information to return if an error occurs, a list of authorized ports that it can use, and transaction parameters. Each PL/SQL agent is associated with a DAD. |
Oracle Web Application Servers comes with a set of prewritten PL/SQL packages called the PL/SQL toolkit. To install the PL/SQL Web Toolkit, use the PL/SQL agent administration forms that are created with the Web server installation. The installation procedure grants the CONNECT and RESOURCE roles to the database user and executes the $ORAWEB_HOME/ admin/owains.sql script, which installs the packages in the PL/SQL Web Toolkit. When the owains.sql script is run manually; you should launch it from Server Manager or SQL worksheet (part of Enterprise Manager). If you want to run it from SQL*Plus, see the header of the script for instructions.
The packages are installed in the user's schema. This ensures that the user can't use the subprograms in the packages to access data in another user's schema.
Figure 26.12 shows the components of an URL. The Web Application Server comes with the Web Application Server Manager, which is a set of HTML forms you use to configure the PL/SQL Cartridge, the PL/SQL agent, and the Data Access Descriptor (DAD). On these forms you enter information such as virtual paths for the PL/SQL Cartridge, the SQL*Net/Net8 service name for the DAD, and the error-reporting level for the PL/SQL agent. Figure 26.13 shows the configuration of a PL/SQL cartridge in the Oracle Web Application Architecture. Chapter 19, "Improving Throughput with SQL, PL/SQL, and Precompilers," and Appendix A, "Essential PL/SQL: Understanding Stored Procedures, Triggers, and Packages," provide more information on PL/SQL.
Sequence of events observed when a PL/SQL Cartridge request is made
Java is a object-oriented programming language developed by Sun Microsystems. Java has rapidly evolved into a variety of network computing and Web architectures. What makes Java so exciting is the promise of platform independence. In keeping with the popularity of Java, Oracle Corporation has developed a Java cartridge. An HTTP request routed to the Java Cartridge is processed by running a Java application that returns the HTTP response.
The Java Cartridge doesn't support Java applets (programs written in Java that can be downloaded over the network and run in a Web browser), but supports only Java applications. Java applications are loaded from a trusted file system (which is mapped to by the Web Server).
When the listener component of the Web Application Server receives requests for the Java Cartridge from browsers, the Java Cartridge interprets information in the URL to identify the Java application that should handle the request. The Java application then programmatically responds to the client, performs interim tasks, accesses a database, or performs other computing tasks. Ultimately, the Java application sends a response back through the Java Virtual Machine (JVM) and the Web Application Server to the client. Figure 26.13 shows the Java cartridge in the architecture of the Oracle Web Application Server.
Sequence of events observed when a Java Cartridge request is made
Oracle Advanced Queuing (Oracle AQ) is an Oracle8 feature that integrates a messaging queuing system with the Oracle8 Server (Enterprise Edition). This allows you to store messages into queues that can be retrieved and processed when needed. The real advantage of advanced queuing is that it's an integrated and reliable queuing system that works without any extra middleware software. Applications access the queues through a PL/SQL interface.
| Availability of Oracle AQ with Oracle Enterprise Edition |
Oracle AQ isn't available with Oracle8 version of the product; it's available with the Enterprise Edition of the server. To take advantage of the full functionality of Oracle AQ option, you'll also need the Enterprise Edition version of Oracle8 with the Objects Option. |
| Using the DBMS_AQADM package |
Oracle AQ provides a package called DBMS_AQADM that's used for creating, stopping, altering, starting, and dropping queues. |
Oracle AQ has certain terms and definitions typical to a messaging system. Let's take a quick look at some of the terms:
| Suggested reading for more information on AQ |
For more information about Advanced Queuing, read the chapter on Advanced Queuing included in the Oracle8 Server Application Administrator's Guide in the Oracle documentation set. In particular, a section in this chapter titled "Advanced Queuing by Example" deserves special mention, because it has several scenarios and situations worth reading. |
Oracle AQ has the following major features:
© Copyright, Macmillan Computer Publishing. All rights reserved.