Professional Documents
Culture Documents
Student Name: Karthik Bala Manokaran Student ID: 3138610 Department: CIS-Data Science-21SP
Student Name: Karthik Bala Manokaran Student ID: 3138610 Department: CIS-Data Science-21SP
Input:
--KarthikBala--
var g_shopper Number;
Begin
:g_shopper:=99;
End;
DECLARE
lv_tot_num bb_basket.total%TYPE;
BEGIN
SELECT total
INTO lv_tot_num
FROM bb_basket
WHERE idshopper = :g_shopper;
Exception
when NO_DATA_FOUND then
dbms_output.put_line('Invalid Shopper ID');
End;
/
GCIS_5160A_Data Centric Concepts_Assignment-4
Output:
Invalid Shopper ID
Input:
--Karthik Bala--
ALTER TABLE bb_basketitem
ADD CONSTRAINT bbitems_qty_chk CHECK (quantity<20);
DECLARE
ex_bitems_ck EXCEPTION;
PRAGMA EXCEPTION_INIT(ex_bitems_ck, -2290);
BEGIN
INSERT INTO bb_basketitem
VALUES (78,7,6,22,16,2,3);
EXCEPTION
WHEN ex_bitems_ck THEN
DBMS_OUTPUT.PUT_LINE('Check Quantity');
END;
/
GCIS_5160A_Data Centric Concepts_Assignment-4
Output:
Table BB_BASKETITEM altered.
Check Quantity.
Input:
--Karthik Bala--
var g_old number;
var g_new number;
Begin
:g_old:=30;
:g_new:=4;
End;
Declare
ex_id_fk EXCEPTION;
PRAGMA EXCEPTION_INIT(ex_id_fk, -02291);
BEGIN
UPDATE
bb_basketitem
SET
idBasket = :g_old WHERE idBasket = :g_new;
EXCEPTION
WHEN ex_id_fk THEN
DBMS_OUTPUT.PUT_LINE('Invalid original basket ID');
GCIS_5160A_Data Centric Concepts_Assignment-4
END;
/
Output:
Input:
---Karthik Bala---
/*CREATE TABLE employee(EMPLOYEE_ID NUMBER(4),ENAME VARCHAR2(10),JOB
VARCHAR2(9),SALARY NUMBER(7,2));
INSERT INTO employee VALUES (12,'Karthik','Developer',1000);
INSERT INTO employee VALUES (15,'Bala','President',3000);*/
DECLARE
CURSOR c_emp IS
SELECT * FROM employee;
inc_salary NUMBER(7,2);
total_cost_inc_ NUMBER(13,2):=0;
BEGIN
FOR c2 IN c_emp LOOP inc_salary:=0;
IF(c2.Job ='President') THEN
inc_salary:=0;
ELSE
inc_salary:=least(2000,round(c2.salary*6/100,2));
END IF;
GCIS_5160A_Data Centric Concepts_Assignment-4
total_cost_inc_:= total_cost_inc_+inc_salary;
dbms_output.put_line('New Salary for Employee: '||c2.employee_id||'-'||
c2.ename||' is');
dbms_output.put_line(nvl(c2.salary,0)+nvl(inc_salary,0));
UPDATE employee SET salary=salary+inc_salary
WHERE employee_id=c2.employee_id;
dbms_output.put_line('Details for Empno:'||c2.employee_id);
dbms_output.put_line('Name:'||c2.ename||' Job:'||c2.Job);
dbms_output.put_line('Current annual Salary:'||c2.salary*12);
dbms_output.put_line('Monthly raise:'||inc_salary);
dbms_output.put_line('Annual raise:'||inc_salary*12);
dbms_output.put_line('New Annual Salary: '||
(nvl(c2.salary,0)+nvl(inc_salary,0))*12);
END LOOP;
dbms_output.put_line('Total Cost of All employees salary is:'||total_cost_inc_*12);
COMMIT;
END;
/
Output:
New Salary for Employee: 12-Karthik is
1338.23
Details for Empno:12
Name:Karthik Job:Developer
Current annual Salary:15149.76
Monthly raise:75.75
Annual raise:909
GCIS_5160A_Data Centric Concepts_Assignment-4