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.
You might also like to view...
The following statement __________
``` cin >> *num3; ``` a. stores the keyboard input in the variable num3 b. stores the keyboard input into the pointer num3 c. is illegal in C++ d. stores the keyboard input into the variable pointed to by num3 e. None of these
The ____ panel includes different options used to align a group of selected objects on the Stage.
A. Display B. Center C. Select D. Align
If a VBA error occurs while Access is running a procedure, you are offered the choice of ending the procedure or entering debugging mode. Choosing to enter debugging mode opens the Visual Basic Editor with the incorrect line of code highlighted in ________
A) green B) yellow C) blue D) gray
A scenario is a set of values that Excel saves and can substitute automatically in your worksheet
Indicate whether the statement is true or false