PR 22 26
PR 22 26
PR 22 26
XI
1.
DECLARE
a NUMBER;
b NUMBER;
result NUMBER;
BEGIN
BEGIN
A:=&a;
B:=&b;
result := a / b;
DBMS_OUTPUT.PUT_LINE('Result: ' || result);
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Error: Division by zero');
END;
END;
2.
Declare
C_id customer.id%type;
C_name Customer.name%type;
C_addr customer.addr%type;
C_sal customer.Sal%type;
Begin
C_id:=&C_id;
Select ID, Name, Addr, Sal into C_id, C_name , C_addr, c_Sal from Customer where
Id=C_id;
Dbms_Output.Put_line('ID: '|| C_id);
Dbms_Output.Put_line('Name: '|| C_Name);
Dbms_Output.Put_line('Addr: '|| C_addr);
Dbms_Output.Put_line('Sal: '|| C_Sal);
Exception
When no_data_found Then
Dbms_Output.Put_line(' Employee Id Not Found');
When Others then
Dbms_Output.Put_line('Errors');
End;
/
PR-23
XI
1.
2.
Declare
C_id customer.id%type:=&CC_id;
C_name Customer.name%type;
C_addr customer.addr%type;
C_sal customer.Sal%type;
ex_invalid_id Exception;
Begin
If C_id <=0 then
Raise Ex_invalid_id;
Else
Select ID, Name, Addr, Sal into C_id, C_name , C_addr, c_Sal from
Customer where Id=C_id;
Dbms_Output.Put_line('ID: '|| C_id);
Dbms_Output.Put_line('Name: '|| C_Name);
Dbms_Output.Put_line('Addr: '|| C_addr);
Dbms_Output.Put_line('Sal: '|| C_Sal);
End if;
Exception
When ex_invalid_id then
Dbms_Output.Put_line(' ID must be greater than zero! ');
When no_data_found then
Dbms_Output.Put_line(' Employee Id not Exist');
When Others then
Dbms_Output.Put_line('Errors');
End;
/
PR-24
XI
1.
Begin
end;
Sql> print k;
2.
2.
1.
create or replace trigger tr2 before update on account for each row
begin
end;
2.