Write PL/SQL or T-SQL procedures to accomplish the following tasks:a. Obtain the first name and last name of the owner whose number currently is storedin I_OWNER_NUM. Place these values in the variables I_FIRST_NAME andI_LAST_NAME. Output the contents of I_OWNER_NUM, I_FIRST_NAME, andI_LAST_NAME.
Create or replace PROCEDURE OWNER_PROCE
(
I_OWNER_NUM NUMBER
)
AS
--when declaring
-- variable's type, we can reference
--table.column%TYPE to use the
-- type of an existing column.
I_FIRST_NAME OWNER.firstname%TYPE;
I_LAST_NAME OWNER.lastname%TYPE;
BEGIN
-- SELECT and return column values into the
-- variables. If
-- the OWNER NUMBER ID isn't found, Oracle
--will throw and you can pick
-- up the pieces in the EXCEPTION block
--below.
SELECT firstname,lastname INTO
I_FIRST_NAME,I_LAST_NAME
FROM OWNER
WHERE OwnerNumber = I_OWNER_NUM ;
-- this means the query above found one a
--only one row, and ththen it put values --into the variables. Print out the
-- variables.
DBMS_OUTPUT.PUT_LINE('OWNER_NUM: ' || I_OWNER_NUM);
DBMS_OUTPUT.PUT_LINE('FIRST_NAME: ' || I_FIRST_NAME);
DBMS_OUTPUT.PUT_LINE('LAST_NAME: ' || I_LAST_NAME);
EXCEPTION
-- If the query didn't find a row you'll end up here. In this case,
-- there's no need for any type of fancy exception handling; just
-- reporting that the Owner wasn't found is enough.
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('Owner number ' ||I_OWNER_NEM|| ' not found.');
END;
NOTE: here, you should give the name of tables and field name. But you didnt. So I assume the table as OWNER and number of owner as OwnerNumber first name as firstname and last name as lastname.
Write PL/SQL or T-SQL procedures to accomplish the following tasks:a. Obtain the first name and last...
Write an SQL statement that will display the Employee ID, First name (only last 2 letters), phone number (replace . by /) of all employees whose job Id has a word ‘REP’.
(PL/SQL Programming) Consider the table EMPLOYEE with attributes ID, Name, and Hours, and the table PAYINFO with attributes Regular, Overtime, and HourLimit, defined and populated by the following script: DROP TABLE EMPLOYEE CASCADE CONSTRAINTS; CREATE TABLE EMPLOYEE ( ID CHAR(5), Name VARCHAR2(16), Hours NUMBER(2), CONSTRAINT PK_EMPLOYEE PRIMARY KEY (ID) ); INSERT INTO EMPLOYEE VALUES ('22144', 'Anderson', 30); INSERT INTO EMPLOYEE VALUES ('31902', 'Bruford', 45); INSERT INTO EMPLOYEE VALUES ('42771', 'Wakeman', 20); INSERT INTO EMPLOYEE VALUES...
I need to write a SQL query that displays the first name and last name of each author along with the number of books he or she has written. Capitalize the first and last names. AUTHOR table: AUTHORID, LNAME, FNAME BOOKAUTHOR table: ISBN, AUTHORID BOOKS table: ISBN, TITLE, PUBDATE, PUBID, COST, RETAIL, DISCOUNT, CATEGORY
Q2 Given the following emp_tbl: (CLOI) 6 Marks first name Ahmad last name Salah Ali Hassan salary 10,000 9,000 ,000 empID Amira 200 300 Saeed (i) Write a P/SQL procedure that: a. Declares two variables of type first_name and salary columns, respectively. b. Declares a cursor that includes the first_name and salary columns. c. Fetches the values in the cursor into the declared variables. d. Prints these values in the following form: First name Salary Ahmad 10,000 Amira 9,000 7,000...
write SQL code to list the employee first name, last name, and salary from the employee table and the department from the jobs table
Given the following table structure, write the SQL code to display all the first and last names of the individuals that have a last name that begins with the letter 'M! CREATE TABLE Persons Personi int LastName varchar(80). FirstName varchar(80). Address varchar(125). State char(2) Given the following table structure, write the SQL code to display all the first and last names of the individuals that have a last name that does not contain the letter 'S: CREATE TABLE Persons PersonlDint,...
1) Write SQL to return the first and last name of all actors with a first name of "ADAM" (use the ACTOR table) 2) Write SQL with the LIKE operator to return addresses that are in the "Dhaka" district and have street addresses that do not contain the character sequence "Loop". You can return all information from the ADDRESS table that matches this criteria. 3) Write SQL with the BETWEEN and ORDER BY clause to return the payments in descending...
1. Write a query to list the first name and last name of those pilots who were hired after January 1, 2010. Sort your result by the ascending order of last name. Within matching last names, order by first name. 2. Write a query to list flight number, pilot number, pilot last name for all flights whose destinations are using the IN keyword. 3. Write a query to list the names and telephone numbers of the passengers who have reservations...
Database Management.... Write the SQL command that would, for each author, list the last name, first name, and title and book type of all books written by her or him that we carry,
SQL query: Write an SQL query that will output the last name, employee id, hire date and department from the employee table. Pick only those employees whose department ID is specified in the employee table. If the employee id is 777, name is ABC and hire date is 01-JAN-2016, the output should look as follows - 'Stephen (Employee ID - 777) was hired on the 1st of January, 2016 – Department: 90'. Note - The date should not have preceding...