PLSQL ALL Program
PLSQL ALL Program
Declare
a number;
b number;
c number;
Begin
dbms_output.put_line('Enter a:');
a:=&a;
dbms_output.put_line('Enter b:');
b:=&b;
dbms_output.put_line('Enter c:');
c:=&C; if (a>b) and (a>c) then
dbms_output.put_line('A is GREATEST'||A);
elsif (b>a) and (b>c) then
dbms_output.put_line('B is GREATEST'||B);
else
dbms_output.put_line('C is GREATEST'||C);
end if;
End;
Important PL SQL Programs
Explicit Cursor
DECLARE
id customer.id%type;
name customer.name%type;
salary customer.salary%type;
CURSOR c_customer is
SELECT id, name, salary FROM customer;
BEGIN
OPEN c_customer;
LOOP
FETCH c_customer into id, name, salary;
EXIT WHEN c_customer%notfound;
dbms_output.put_line(id || ' ' || name || ' ' || salary);
END LOOP;
CLOSE c_customer;
END;
Implicit Cursor
execute v1;
RETURN total;
END;
/
Important PL SQL Programs
Declaring Function:
DECLARE
c number(5);
BEGIN
c := totalCustomer();
dbms_output.put_line('Total no. of Customer: ' || c);
END;
Trigger
1) Create table main(id int, salary int);
2) Create table backup(id int, salary int);
Create trigger
Create or replace trigger t1
before delete on main
for each row
begin
insert into backup values(:old.id, :old.salary);
end;
Types of Triggers
1)DDL Triggers
2)DML Triggers
3)Logon Triggers