Oracle PL SQL 2
Oracle PL SQL 2
Oracle PL SQL 2
Invalid Identifiers:
• The identifier must not start with a digit or special character (except underscore).
• The identifier must not contain spaces or any special characters other than an underscore.
123employee
department-id
employee name
SELECT
A delimiter is a symbol with a special meaning. Following is the list of delimiters in PL/SQL
A delimiter is a symbol with a special meaning. Following is the list of delimiters in PL/SQL:
Data types
1. NUMBER This data type is used to store numeric values. It can handle both integer and
floating-point numbers.
2. VARCHAR2 This data type is used to store character strings of varying lengths. The
maximum length allowed is 32767 bytes.
3. CHAR This data type is used to store fixed-length character strings. It is similar to
VARCHAR2, but it pads the string with spaces to the fixed length if the actual
string is shorter.
4. DATE: This data type is used to store date and time values. It can store dates from
January 1, 4712 BC, to December 31, 9999 AD with a precision of up to one
second.
This data type is used to store logical values, such as TRUE or FALSE.
5. BOOLEAN
6. BLOB This data type is used to store binary large objects, such as images, audio files,
or video files.
7. CLOB This data type is used to store character large objects, such as large text
documents.
8. RAW This data type is used to store raw binary data. It can store up to 2000 bytes.
10. INTERVAL This data type is used to store intervals of time. It can store the difference
between two dates or timestamps.
11. ROWID This data type is used to store the unique address of a row in a database table.
12. UROWID This data type is used to store the unique address of a row in a database table in
a universal format.
14. RECORD This data type is used to define a structure containing multiple fields. It is
similar to a struct or record in other programming languages.
15. TABLE This data type is used to define collections of values of the same data type. It
can be used to store multiple rows or columns of data.
In PL/SQL, variables are declared and initialized using the DECLARE statement. The syntax for
declaring and initializing variables is as follows:
DECLARE
...
BEGIN
-- PL/SQL code
END;
DECLARE
BEGIN
-- PL/SQL code
END;
/
In the above example, three variables (employee_name, employee_age, and employee_salary) are
declared and initialized with their respective data types and initial values.
Note: The DBMS_OUTPUT.PUT_LINE() statement is used to display the variable values in the output
console. To see the output, you may need to enable the output display in your PL/SQL IDE or use the
SET SERVEROUTPUT ON command before executing the code.
To use the SET SERVEROUTPUT ON command before executing the code in PL/SQL, you need to
follow these steps:
SET SERVEROUTPUT ON
This command enables the output display for the DBMS_OUTPUT.PUT_LINE() statements in your
PL/SQL code.
Run or execute your PL/SQL code that contains the DBMS_OUTPUT.PUT_LINE() statements.
After executing the code, you should now be able to see the output of the
DBMS_OUTPUT.PUT_LINE() statements in your PL/SQL environment.
An example of how to use the SET SERVEROUTPUT ON command before executing the code in
PL/SQL:
SET SERVEROUTPUT ON
• SET SERVEROUTPUT ON
• DECLARE
• BEGIN
• -- PL/SQL code
• END;
• /