PL-SQL
Oracle PL/SQL Cursor: Implicit, Explicit, Cursor FOR Loop [Example]
What is CURSOR in PL/SQL? A Cursor is a pointer to this context area. Oracle creates context area...
Identifiers are nothing but a name that is given to a PL/SQL object. The object could be constant, variable, exception, cursors, procedures, function, package, trigger, object type, reserve word or label.
In this tutorial, you will learn-
In a complex program, sometimes we may have to include many identifiers. These identifiers include variables, cursors, etc. So to avoid confusion and to increase the readability of such program we need to follow certain naming conventions.
Following are the commonly used naming conventions in PL/SQL.
Below are some of the examples of proper naming conventions
Variable is the basic identifier which is used more frequently and the most important of all. Variable is nothing but a placeholder where the user can store the value. This variable needs to be associated with some valid PL/SQL datatype before using them. The datatype will define the storage and processing method for these variables.
Variables are mainly used to store data during the data manipulation or data processing. They need to be declared before using them inside the program. This declaration needs to be done in the declarative section of the PL/SQL blocks.
Declaration of variables is a process of assigning the name to the placeholder and associate the same with a valid datatype.
Syntax
<variable name> <datatvpe>;
The above syntax shows how to declare the variable in the declarative section.
Once the variable is declared, they are ready to hold the data of defined type. The values of these variables can be assigned either in execution section or at the time of declaring itself. The value can be either a literal or another variable's value. Once a particular value has been assigned, it will be stored in the allocated memory space for that variable.
Syntax
<variable_name> <datatype> := <default_value>;
The above syntax shows how to declare the variable and assign value in the declarative section.
<Yariable_name> <datatype>; <variable name> := <value>;
The above syntax shows how to assign the value to an already declared variable.
Example1: In this example, we are going to learn how to declare the variable and how to assign the value to them. We are going to print 'gtupapers' in the following program by using the variables.
DECLARE lv_name VARCHAR2(50); lv_name_2 VARCHAR2(50) := ‘gtupapers'; BEGIN lv_name := lv_name_2; dbms_output .put_line(lv_name); END:
Code Explanation:
When the above code is executed, you will get the following output.
Output:
gtupapers
In this tutorial, we have discussed what is an identifier and their properties. We have also discussed naming conventions for identifiers as well as about declaring and using the variable in programs.
What is CURSOR in PL/SQL? A Cursor is a pointer to this context area. Oracle creates context area...
In this tutorial, you are going to see the detailed description on how to create and execute the...
What is Nested Blocks Oracle? In PL/SQL, each block can be nested into another block. They are...
In this tutorial, we will introduce SQL* Plus and learn how to connect it to the database. After...
In this tutorial, we are going to learn how to use SQL in PL/SQL. SQL is the actual component that...
Download PDF 1) What is PL SQL ? PL SQL is a procedural language which has interactive SQL, as well as...