PLSQL 2 5 SG PDF
PLSQL 2 5 SG PDF
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 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 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:
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