Block & Variables
Q : What is Block?
A : It is a unit of code that is to
declare a data operation and create a logical operation for database.
syntax:
Declare
Begin
End;
Declare: Declare section means, we can write the variables.
Begin and End: This is the main body of the block Where we can write the Pl/SQL Functions, SQL
Statements, Procedures, packages, Cursors.
Variables:
These are designated storage spaces
inside a block, process, function, or package that are used to temporarily keep
data.
The types of data they can store are limited
by a certain data type.
Types of Variables
1.Types of Numbers:
· NUMBER: Applied to precise and scaled
numerical numbers.
· INTEGER:Whole integers without decimal places.
· DECIMAL, REAL, FLOAT: Numbers with floating-point
precision.
2. Character and String Types:
· CHAR: Stores character strings (fixed length).
· VARCHAR: Stores character strings (Variable
length).
· VARCHAR2: Stores variable-length character
strings.
· CLOB: Large object for storing large amounts
of character data.
3. Date Type:
· DATE: Stores date and time information.
4.Boolean Type:
· BOOLEAN: Represents true or false values.
5. LOB Types:
· BLOB: Stores binary large objects.
DECLARE
l_number NUMBER := 20;
l_name VARCHAR2(100) := 'Ram';
l_present_date DATE := SYSDATE;
BEGIN
dbms_output.put_line('The age of '
|| l_name
|| ' is '
|| l_number
|| ' until today date '
|| l_present_date);
END;
Example-2:
DECLARE
l_present_date DATE;
BEGIN
INTO l_present_date
FROM dual;
END;
No comments:
Post a Comment