PL/SQL - Constants and Attributes

PL/SQL - Constants and Attributes
A constant has to declared and initialized in the declare block only using CONSTANT keyword
Constant Value cannot be changed

declare
r CONSTANT number :=100;
begin
/*   r := r + 100; Not possible*/
dbms_output.put_line(r);
end;

/*Assigning value to variable from a column of a table using select into clause*/

declare
salary number;
begin
Select sal Into salary from emp
where ename = 'HAREESH;
dbms_output.put_line('Salary of HAREESH is '|| salary);
end;

/* Selecting ename,sal from emp
Use of more than one columns value with Into clause*/

declare
empname varchar2(50);
salary number;
begin
select ename, sal Into empname, salary
from emp
where ename = 'HAREESH';
dbms_output.put_line(empname);
dbms_output.put_line(salary);
end;
*/

No comments:

Post a Comment