Name four standard scalar data types used in PL/SQL. When is each type used for variables?

What will be an ideal response?

CHAR.   The CHAR data type is used for fixed-length string values. The allowable
string length is between 1 and 32,767. If you remember, the allowable length in the
Oracle database is only 2000. If you do not specify a length for the variable, the default
length is 1. Get into the habit of specifying length along with the data type to avoid any
errors.
VARCHAR2.   The VARCHAR2 type is used for variable-length string values. The
allowable length is between 1 and 32,767. Again, a column in an Oracle database with a
VARCHAR2 type can only take 4000 characters, which is smaller than the allowable
length for the variable.
NUMBER
PL/SQL has a variety of numeric data types. You are familiar with the NUMBER type
from Oracle table’s column type. The NUMBER type can be used for fixed-decimal-
point or floating-decimal-point numbers. It provides accuracy of up to 38 decimal
places. When using the NUMBER type, the precision and scale values are provided. The
precision of a number is the total number of significant digits in that number, and the
scale is the number of significant decimal places. The precision and scale values must be
whole-number integers, for example,

NUMBER (p, s)

If scale has a value that is negative, positive, or zero, it specifies rounding of number to
the left of decimal place, to the right of decimal place, or to the nearest whole number
respectively. If a scale value is not used, no rounding occurs.
BOOLEAN
PL/SQL has a logical data type, Boolean, that is not available in SQL. It is used for
Boolean data TRUE, FALSE, or NULL only. These values are not enclosed in single
quotation marks like character and data values.
DATE
The date type is a special data type that stores date and time information. The date values
have specific format. A user can enter a date in many different formats with the
TO_DATE function, but a date is always stored in standard 7 byte format. A date stores
the following information:
Century, Year, Month, Day, Hour, Minute, Second
The valid date range is from January 1, 4712 B.C. to December 31, 9999 A.D. The time is
stored as number of seconds past midnight. If the user leaves out the time portion of the
data, it defaults to midnight (12:00:00 A.M.). Various DATE functions are available for
date calculations. For example, the SYSDATE function is used to return the system’s
current date.

Computer Science & Information Technology

You might also like to view...

You can deselect the ________ checkbox in the Printed Watermark dialog box to make a watermark darker

A) Darken B) Semitransparent C) Color D) Remove

Computer Science & Information Technology

The box on a slide that has a dotted or hatch-marked border and that contains the insertion point is a text ____.

A. placeholder B. pane C. layout D. recorder

Computer Science & Information Technology