100% found this document useful (1 vote)
124 views30 pages

PLSQL 2 5 SG PDF

The document discusses variable assignment in PL/SQL. It states that in an assignment, the variable is always on the left side of the assignment symbol (:=) and the value is always on the right side. It provides an example where the value in variable v_count plus the value in variable c_people is assigned to variable v_num. Functions are also discussed as blocks of code that are used to accomplish specific processes and make writing programs easier.

Uploaded by

patricia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
124 views30 pages

PLSQL 2 5 SG PDF

The document discusses variable assignment in PL/SQL. It states that in an assignment, the variable is always on the left side of the assignment symbol (:=) and the value is always on the right side. It provides an example where the value in variable v_count plus the value in variable c_people is assigned to variable v_num. Functions are also discussed as blocks of code that are used to accomplish specific processes and make writing programs easier.

Uploaded by

patricia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

2

3
4
Assigning a value to a variable: the variable must always be on the left side of the assignment symbol (:=);
the value will always be on the right side of the assignment symbol.

v_num := v_count + c_people

v_num is the variable memory location that will be assigned the value in the variable memory location
v_count plus the value of the memory location c_people.

5
Functions are used as short cuts. Someone already programmed a block of code to accomplish a specific
process. These blocks of code are called procedures and functions. Use them to make writing your program
easier. Later in this course, you will learn how to write your own procedures and functions.

6
7
8
9
10
11
12
13
14
15
Whenever PL/SQL detects that a conversion is necessary, it attempts to change the values as required to
perform the operation.

In the chart, the cells marked 'X' show which implicit conversions can be done.

For this course, we will focus on implicit conversions between:

Characters and numbers


Characters and dates

For more information about the above chart, refer to “Converting PL/SQL Data Types” in the PL/SQL User’s
Guide and Reference.

16
17
18
19
20
21
22
23
The examples in the slide show implicit and explicit conversions of the DATE data type.

Example #1 - Implicit conversion happens in this case and the date is assigned to v_date_of_joining.

Example #2 - PL/SQL gives you an error because the date that is being assigned is not in the default format.

Example #3 - This is how it should be done. Use the TO_DATE function to explicitly convert the given date in
a particular format and assign it to the DATE data type variable date_of_joining.

24
25
26
The second example is particularly elegant when you consider the same result could be obtained by the
following code:

IF v_sal BETWEEN 50000 AND 150000 THEN


v_good_sal := TRUE;
ELSE
v_good_sal := FALSE;
END IF;

27
• Explicit conversion – Converts values from one data type to another by using built-in functions.
• Implicit conversion – Converts data types dynamically if they are mixed in a statement.

28
29

You might also like