Question
answer the question which is in the paper and add two cursor after question 4 with a screenshot please CREATE TABLE Product143( productNO char(10), label
answer the question which is in the paper and add two cursor after question 4 with a screenshot please
CREATE TABLE Product143( productNO char(10), label varchar(30), price decimal(9,2), QStock INTEGER(11), PRIMARY KEY(productNO) );
INSERT INTO Product Values ('CS262','Chev.fir 200x6x2',75,45);
INSERT INTO Product Values ('CS264','Chev.fir 200x6x4',120 ,2690);
INSERT INTO Product Values ('CS464','Chev.fir 400x6x4', 220,450);
INSERT INTO Product Values ('PA45','Steel point 45 (1K)', 105,580);
INSERT INTO Product Values ('PA60','Steel point 60 (1K)', 95,134);
INSERT INTO Product Values ('PH222','PL.Hetre 200x20x2', 230,782);
INSERT INTO Product Values ('PS222','PL.fir 200x20x2', 185,1220);
INSERT INTO Product Values ('TRT989','Chev.fir 210x5x2',75,45);
INSERT INTO Product Values ('CS954','Chev.fir 260x7x4',170 ,2690);
INSERT INTO Product Values ('GH454','Chev.fir 350x8x4', 220,450);
INSERT INTO Product Values ('PN60','Steel point 66 (1K)', 145,590);
INSERT INTO Product Values ('JK50','Steel point 50 (1K)', 35,754);
CREATE TABLE orderedProduct( orderNO int, productNo varchar(5), orderQuantity int NOT NULL, FOREIGN KEY (orderNO) REFERENCES customerOrder(orderNO), FOREIGN KEY (productNo) REFERENCES Product(productNo),
INSERT INTO orderedProduct Values ( 30178,'CS464', 25);
INSERT INTO orderedProduct Values ( 30179,'CS262', 60);
INSERT INTO orderedProduct Values ( 30179,'PA60', 20);
INSERT INTO orderedProduct Values ( 30182,'PA60', 30);
INSERT INTO orderedProduct Values ( 30184,'CS464', 120);
INSERT INTO orderedProduct Values ( 30184,'PA45', 20);
INSERT INTO orderedProduct Values ( 30185,'CS464', 260);
INSERT INTO orderedProduct Values ( 30185,'PA60', 15);
INSERT INTO orderedProduct Values ( 30186,'PS222', 600);
INSERT INTO orderedProduct Values ( 30186,'PA45', 3);
INSERT INTO orderedProduct Values ( 30188,'PA60', 180);
INSERT INTO orderedProduct Values ( 30188,'PH222', 92);
INSERT INTO orderedProduct Values ( 30745,'GH564', 65); INSERT INTO orderedProduct Values ( 30632,'GF732', 10); INSERT INTO orderedProduct Values ( 30074,'JW660', 50); INSERT INTO orderedProduct Values ( 39935,'TY60', 30); INSERT INTO orderedProduct Values ( 34367,'GH664', 120);
CREATE TABLE Customer143(
customerNO char(8),
customerName varchar(20),
address VARchar(40),
city varchar(20),
category char(2),
custBalance decimal(9,2),
PRIMARY KEY(customerNO)
);
INSERT INTO Customer Values ('B062','Ahmed','72 street Freedom','Salalah','B2',-100);
INSERT INTO Customer Values ('B112','Salim','Street Sultan Qaboos','Muscat','C1', 1250);
INSERT INTO Customer Values ('B332','Alia','Building Hana Street Alhisn ','Ibri','B2', 0);
INSERT INTO Customer Values ('B512','Taoufiq','Building Alaamra','Rustaq','B1', -500);
INSERT INTO Customer Values ('C003','Islam','House N 5 Street Asahafa','Salalah','B1', -1000);
INSERT INTO Customer Values ('C123','Murad','Building Asalalm Main Street','Ibri','C1', -2000);
NSERT INTO Customer Values ('C400','Jamilah','Street of garden House n 5','Muscat','B2', 350);
INSERT INTO Customer Values ('B062', 'Ahmed', '55 FINS BEACH', 'QURAIT', '42', 60);
INSERT INTO Customer Values ('B112', 'REEM', 'Street Sultan Qaboos', 'Muscat', 'H6', 150);
INSERT INTO Customer Values ('B332', 'Ali', 'WADI SHAB ','SUR', 'G4', 0);
INSERT INTO Customer Values ('B512', 'RANA', 'NIZWA FORT', 'NIZWA', 'VI', 100);
INSERT INTO Customer Values ('C003', 'WAFA', 'AL ALAM PALACE', 'MUSCAT', 'KL', 900);
1) Open SQL Developer then load the Schema_creation.sql and table_population.sql scripts to create and populate the tables discussed in assignment I. Open a new SQL worksheet then write the PL/SQL code that creates the following objects. 2) Create in PL/SQL a stored procedure called 'Del_Details' to delete the record of orderedProduct table for which it receives as input the order number (orderNO) and the product number (productNO). [1.5] 3) Create in PL/SQL a stored Function called 'productPerOrder' to return the number of products placed for any order its number is given as input. [1.5] 4) Write a Trigger called "changeCustomer_Category'. This trigger should be invoked before any update of customer balance in customer table. Its job is to modify the category of a customer from B2 to B1 and from C2 to C1 when a customer's balance status drops below a certain threshold (-10000).[2]Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started