Oracle7 Server Concepts

Contents Index Home Previous Next

Data Conversion

In some cases, Oracle supplies data of one datatype where it expects data of a different datatype. This is allowed when Oracle can automatically convert the data to the expected datatype using one of the following functions:

Implicit datatype conversions work according to the rules explained in the following two sections.

Note: If you are using Trusted Oracle, see the Trusted Oracle7 Server Administrator's Guide for additional information involving data conversions and the MLSLABEL and RAW MLSLABEL datatypes.

Rule 1: Assignments

For assignments, Oracle can automatically convert the following:

The assignment succeeds if Oracle can convert the datatype of the value used in the assignment to that of the assignment's target.

Note: For the examples in the following list, assume a package with a public variable and a table declared as in the following statements:

			var1	CHAR(5);  
			CREATE TABLE table1 (col1 NUMBER); 

			VAR1 := 0 

			INSERT INTO table1 VALUES ('19'); 

			UPDATE table1 SET col1 = '30'; 

			SELECT col1 INTO var1 FROM table1 WHERE col1 = 30; 

Rule 2: Expression Evaluation

For expression evaluation, Oracle can automatically convert the following:

Some common types of expressions follow:

In general, Oracle uses the rule for expression evaluation when a datatype conversion is needed in places not covered by the rule for assignment conversions.

In assignments of the form

variable := expression 

Oracle first evaluates expression using the conversions covered by Rule 2; expression can be simple or complex. If it succeeds, expression results in a single value and datatype. Then, Oracle tries to assign this value to the assignment's target using Rule 1.

CHAR to NUMBER conversions only succeed if the character string represents a valid number. CHAR to DATE conversions only succeed if the character string has the default format 'DD-MON-YY'.


Contents Index Home Previous Next