SQL code for:
Create a stored procedure “setRelocationFee” to set the relocation fee for a given
employee. If the employee’s office is in San Francisco, the relocation fee is $10000; if
the employee’s office is in Boston, the relocation fee is $8000; if the employee’s office
is in London, the relocation fee is $20000; if the employee works in other offices, the
relocation fee is $15000.
Below is a sample statement to test your stored procedure.
set @employeeID = 1501;
call setRelocationFee(@employeeID, @relocationfee);
select @employeeID, @relocationfee;
Having this
CREATE TABLE `offices` (
`officeCode` varchar(10) NOT NULL,
`city` varchar(50) NOT NULL,
`phone` varchar(50) NOT NULL,
`addressLine1` varchar(50) NOT NULL,
`addressLine2` varchar(50) DEFAULT NULL,
`state` varchar(50) DEFAULT NULL,
`country` varchar(50) NOT NULL,
`postalCode` varchar(15) NOT NULL,
`territory` varchar(10) NOT NULL,
PRIMARY KEY (`officeCode`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `employees` (
`employeeNumber` int(11) NOT NULL,
`lastName` varchar(50) NOT NULL,
`firstName` varchar(50) NOT NULL,
`extension` varchar(10) NOT NULL,
`email` varchar(100) NOT NULL,
`officeCode` varchar(10) NOT NULL,
`reportsTo` int(11) DEFAULT NULL,
`jobTitle` varchar(50) NOT NULL,
PRIMARY KEY (`employeeNumber`),
KEY `reportsTo` (`reportsTo`),
KEY `officeCode` (`officeCode`),
CONSTRAINT `employees_ibfk_2` FOREIGN KEY (`officeCode`) REFERENCES `offices` (`officeCode`),
CONSTRAINT `employees_ibfk_1` FOREIGN KEY (`reportsTo`) REFERENCES `employees` (`employeeNumber`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps
- SQL CODE FOR For the players who show up in Batting, Bowling, and Fielding tables, create a list that shows their names, runs they have scored, wickets they have taken, and catches they have taken? table is in picture (bowling table is same as batting and fielding )arrow_forwardDepartment DepartmentID DName ContactNo 1 UIIT 0300-1234567 2 UIMS 0300-4567891 Student RollNo Sname Fname DepartmentID 111 Ali Ahmed 1 112 Sana Waqar 2 113 Afzal Ikram 2 There are only two departments and are already initialized globally, but students can be upto 100 and just defined globally. To maintain how many student’s record have been entered you can use global variable with name as count. Write a C++ program having: A) Structures, structure definitions and required initializations for the above scenario.arrow_forward1. Fill the blanks with the suitable PL/SQL statements that correct each of the errors that appear in the given PL/SQL program. DECLARE CURSOR cursor1 IS SELECT * FROM Students; line cursorl %type; | BEGIN OPEN cursor1; LOOP SELECT cursorl inside line; I DBMS_OUTPUT PUT_LINE(first name= || line.fname || "last name= "| line.Iname); EXIT WHEN Cursor %FOUND; | END LOOP; CLOSE cursor1; END;arrow_forward
- Create a function create_tables that returns a connection to an in-memory SQLite database. This database should have a table employee having the following columns: • full name that cannot be null and is text • age that is an integer and can be null • rating that is float and cannot be null remarks that is text and can be nullarrow_forwardWrite a stored procedure called sp_apply_discount() that will apply percent discount to books in a subject. The stored procedure takes in 2 parameters, percentDiscount (DECIMAL(8,2)) and subject (VARCHAR(120)). Using these parameters, the stored procedure computes the discount for the book cost and stores it in the FINAL_PRICE field. For example, the following stored procedure call: call sp_apply_discount(0.15, 'Database');would compute 15% percent discount from the book cost in the Database subject category and store it in the FINAL_PRICE column as depicted in this image:arrow_forwardCreate a stored procedure that will return the number of customers in a given state. The parameter for your stored procedure should accept the state abbreviation ('UT') and return the results of a query that returns the number of customers in that state.arrow_forward
- Oracle sql Task 2: Write a function that returns how old a book is Published before 2000 ->Book X by author Y is an old book Between 2000 and 2020 -> Book X by author Y is modern 2020 and later -> Book X by author Y is recently published X: book name Y: author namearrow_forwardQ2: Design Database for the following scenario and Write SQL queries. Create an ERD for the following scenario. Suppose there is a grocery store near your house. Following can be considered for ERD: A grocery store may have more than one employee. A grocery store has exactly one manager. The manager has one or more sales men working under him. Grocery store has more than one portion for the products. • Each product has a barcode, name, expired date. Many customers can busy many products, but each product is bought by only one customer. Each customer will get an invoice for his /her purchase. The bill invoice has an id.arrow_forwardISBN Title Author 12345678 The Hobbit J.R.R. Tolkien 45678912 DaVinci Code Dan Brown Your student ID DBS311 Your Name use the following statement to Write the PL/SQL code to create a procedure that accepts a product price and increases it by 10%arrow_forward
- Write SQL code for the following: Create a stored procedure “setRelocationFee” to set the relocation fee for a givenemployee. If the employee’s office is in San Francisco, the relocation fee is $10000; ifthe employee’s office is in Boston, the relocation fee is $8000; if the employee’s officeis in London, the relocation fee is $20000; if the employee works in other offices, therelocation fee is $15000. (see image for table structure) I am stuck for the part that I have to select employeeNumber and officeCode and set the relocationFee to be able to obtain the result but I do not know how. Bellow is what I have gotten. Delimiter| CREATE PROCEDURE setRealocationFee(IN EmployeeID INT(11), OUT realocationFee INT(5))arrow_forwardSQL code for: (1) Hint: A NULL in the hours column should be considered as zero hours. Find the ssn, lname, and the total number of hours worked on projects for every employee whose total is less than 40 hours. Sort the result by lname */ /* (2) For every project that has more than 2 employees working on it: Find the project number, project name, number of employees working on it, and the total number of hours worked by all employees on that project. Sort the results by project number. /* (3) For every employee who has the highest salary in their department: Find the dno, ssn, lname, and salary. Sort the results by department number. */ /* (4) For every employee who does not work on any project that is located in Houston: Find the ssn and lname. Sort the results by lname /* (5) Hint: This is a DIVISION query For every employee who works on every project that is located in Stafford: Find the ssn and lname. Sort the results by lname */arrow_forwardWrite a PL/SQL stored procedure to print number of employees who are working in a job with Title "Tester". Include procedure call also. If the total count of Employees is more than 5 then print "Sufficient number of Employees" If the total count of Employees is less than 5 then print "Insufficient number of Employees" Else print "there are 5 employees". Use Oracle's NO DATA_FOUND build in exception to display the last message. DEPARTMENTS LOCATIONS P DEPARTMENT_ID * DEPARTMENT_NAME MANAGER_ID LOCATION_ID P LOCATION_ID STREET ADDRESS POSTAL_CODE * CITY STATE PROVINCE COUNTRY_ID JOB_HISTORY PF* EMPLOYEE_ID P * START DATE * END DATE F JOB ID F DEPARTMENT_ID EMPLOYEES P EMPLOYEE_ID FIRST NAME * LAST_NAME EMAIL COUNTRIES COUNTRY_ID COUNTRY_NAME F REGION ID PHONE_NUMBER * HIRE DATE F JOB_ID JOBS P JOB_ID * JOB_TITLE MIN_SALARY MAX_SALARY SALARY COMMISSION_PCT MANAGER_ID F REGIONS DEPARTMENT_ID P* REGION_ID REGION_NAME I--arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education