Lab work group 02 28_10_2024
Lab work group 02 28_10_2024
declare
v_first employees.first_name%type;
v_last employees.last_name%type;
v_employee_id employees.employee_id%type;
begin
v_employee_id := :anyempid;
select first_name, last_name into v_first,v_last
from employees
where employee_id=v_employee_id;
dbms_output.put_line('firstname is '||v_first||' lastname is '||V_last);
end;
--read employee id from keyboard and print first and last name on screen using
plsql anonymous block
declare
v_first employees.first_name%type;
v_last employees.last_name%type;
v_employee_id employees.employee_id%type;
begin
v_employee_id := :anyempid;
select first_name, last_name into v_first,v_last
from employees
where employee_id=v_employee_id;
dbms_output.put_line('firstname is '||v_first||' lastname is '||V_last);
dbms_output.put_line('the number of rows retrieved is '||SQL%ROWCOUNT);
end;
--read employee id from keyboard and print first and last name on screen using
--plsql anonymous block
declare
v_first employees.first_name%type;
v_last employees.last_name%type;
v_employee_id employees.employee_id%type;
begin
v_employee_id := :anyempid;
select first_name, last_name into v_first,v_last
from employees
where employee_id=v_employee_id;
dbms_output.put_line('firstname is '||v_first||' lastname is '||V_last);
if sql%FOUND=TRUE then
dbms_output.put_line('YESSSSS I could find someone in the table');
else
dbms_output.put_line('NOOOO, there is n such employeee');
end if;
dbms_output.put_line('the number of rows retrieved is '||SQL%ROWCOUNT);
end;
--read employee id from keyboard and print first and last name on screen using
plsql anonymous block
declare
v_first employees.first_name%type;
v_last employees.last_name%type;
v_employee_id employees.employee_id%type;
begin
select first_name, last_name into v_first,v_last
from employees
where employee_id=999;
declare
v_first employees.first_name%type;
v_last employees.last_name%type;
v_employee_id employees.employee_id%type;
begin
select first_name, last_name into v_first,v_last
from employees;
dbms_output.put_line('firstname is '||v_first||' lastname is '||V_last);
if sql%FOUND=TRUE then
dbms_output.put_line('YESSSSS I could find someone in the table');
else
dbms_output.put_line('NOOOO, there is n such employeee');
end if;
dbms_output.put_line('the number of rows retrieved is '||SQL%ROWCOUNT);
exception
when NO_DATA_FOUND then
dbms_output.put_line('!!!!!could not find any employee with that id');
dbms_output.put_line('!!!!!firstname is '||v_first||' lastname is '||V_last);
if sql%FOUND=TRUE then
dbms_output.put_line('!!!!!YESSSSS I could find someone in the table');
else
dbms_output.put_line('!!!!!NOOOO, there is n such employeee');
end if;
dbms_output.put_line('the number of rows retrieved is '||SQL%ROWCOUNT);
when TOO_MANY_ROWS then
dbms_output.put_line('**************);
dbms_output.put_line('*****firstname is '||v_first||' lastname is '||V_last);
if sql%FOUND=TRUE then
dbms_output.put_line('*****YESSSSS I could find someone in the table');
else
dbms_output.put_line('*****NOOOO, there is n such employeee');
end if;
dbms_output.put_line('the number of rows retrieved is '||SQL%ROWCOUNT);
end;
--read employee id from keyboard and print first and last name on screen using
plsql anonymous block
declare
v_first employees.first_name%type;
v_last employees.last_name%type;
v_employee_id employees.employee_id%type;
begin
select first_name, last_name into v_first,v_last
from employees;
--where employee_id=101;
dbms_output.put_line('firstname is '||v_first||' lastname is '||V_last);
if sql%FOUND=TRUE then
dbms_output.put_line('YESSSSS I could find someone in the table');
else
dbms_output.put_line('NOOOO, there is n such employeee');
end if;
dbms_output.put_line('the number of rows retrieved is '||SQL%ROWCOUNT);
exception
when NO_DATA_FOUND then
dbms_output.put_line('!!!!!could not find any employee with that id');
dbms_output.put_line('!!!!!firstname is '||v_first||' lastname is '||V_last);
if sql%FOUND=TRUE then
dbms_output.put_line('!!!!!YESSSSS I could find someone in the table');
else
dbms_output.put_line('!!!!!NOOOO, there is n such employeee');
end if;
dbms_output.put_line('the number of rows retrieved is '||SQL%ROWCOUNT);
when TOO_MANY_ROWS then
dbms_output.put_line('*****');
dbms_output.put_line('*****firstname is '||v_first||' lastname is '||V_last);
if sql%FOUND=TRUE then
dbms_output.put_line('*****YESSSSS I could find someone in the table');
else
dbms_output.put_line('*****NOOOO, there is n such employeee');
end if;
dbms_output.put_line('the number of rows retrieved is '||SQL%ROWCOUNT);
end;
begin
insert into countries
values('CC','AAAAA',null);
dbms_output.put_line(sql%rowcount);
exception
when DUP_VAL_ON_INDEX then
dbms_output.put_line('pk violation');
end;