DECLARE
Variable_declarations
BEGIN
Program_code
EXCEPTION
Exception_handlers
END;
Below is the basic structure of the PL/SQL program:
Set serveroutput on
Var1 varchar2(20);
Begin
Var1 := ‘welcome’;
Dbms_output.put_line(var1);
Exception
When others then
Dbms_output.put_line(‘It is an exception’);
End;
/
In the declaration section all the variables and constants are defined.
Variable_declarations
BEGIN
Program_code
EXCEPTION
Exception_handlers
END;
Below is the basic structure of the PL/SQL program:
Set serveroutput on
Var1 varchar2(20);
Begin
Var1 := ‘welcome’;
Dbms_output.put_line(var1);
Exception
When others then
Dbms_output.put_line(‘It is an exception’);
End;
/
In the declaration section all the variables and constants are defined.
- In PL/SQL all the errors are handled in the Exception block.
- Begin and End are mandatory statements indicating begin and end of the PL/SQL Block.
- Variables and Constants must be declared first before they can be used.
- The declaration of variables and constants are alike, but constant definitions must contain the keyword CONSTANT and must be assigned a value as part of the definition. Later on any attempts to assign a value to a constant will result in an error message.
- Values can be assigned to variables directly using the “:=” assignment operator, by way of a SELECT ... INTO statement or When used as OUT or IN OUT parameter from a procedure.
No comments:
Post a Comment
Please Provide your feedback here