Create a pl-sql procedure - print out names of employees

Assignment Help Database Management System
Reference no: EM13870163

Suppose you have created tables in assignment 1 as follows

Tables:
Company(cid, cname, city, state) /* city is the company's location, cname is company name */
Employee(eid, ename, street, city, state, salary, cid) /* city is where the employee lives*/
Manages(eid, mid) /* mid is manager's ID*/

Sol:

drop table manages;
drop table employee;
drop table company;

create table company(
cid integer,
cname varchar(30),
city varchar(30),
state varchar(20),
primary key (cid));

create table employee(
eid integer,
ename varchar(30),
street varchar(30),
city varchar(30),
state varchar(20),
salary number,
cid integer,
primary key (eid),
foreign key (cid) references company(cid));

create table manages(eid integer,
mid integer,
primary key(eid,mid),
foreign key(eid) references employee(eid),
foreign key(mid) references employee(eid));

--- assume the following rows been inserted
insert into company values(1, 'First Bank Corp', 'baltimore', 'MD');
insert into company values(2, 'Verizon', 'DC', 'DC');

insert into employee values(1, 'alice','123 street', 'baltimore', 'MD',55000,1);
insert into employee values(2, 'bob','23 street', 'DC', 'DC',80000,1);
insert into employee values(3,'jeff','33 street', 'DC','DC',60000,2);
insert into employee values(4,'susan','33 street', 'DC','DC',80000,2);
insert into employee values(5,'eric','1 street', 'DC', 'DC',90000,2);
insert into employee values(6,'andy','2 street', 'baltimore', 'MD',70000,2);

insert into manages values(2,1);
insert into manages values(3,4);
insert into manages values(4,5);
insert into manages values(6,4);

Please write PL/SQL program for the following problems.

Problem 1: Please create a PL/SQL procedure that given a company name, print out names of employees working at that company. Test your procedure with a company name you have in your company table.

Problem 2: Please create a PL/SQL function get_manager that returns the manager's mid given the name of an employee. If an employee does not have a manger, return a null value. Please write an anonymous PL/SQL program to call this function with some employee name as input, and print out the results. You can assume that each employee has at most one manager.

Reference no: EM13870163

Questions Cloud

Please find this differential equation : y''-y'-2y=sin2x+2eˆ-x     y=? please find this differential equation
Calculating value of revenue by using formula : Define Header files.  Define test()function.Declare revenue() function.Declare predict() function.Declare roundMoney() function.
Determine whether the following series converge or diverge : Determine whether the following series converge or diverge
Create a t account for the allowance for doubtful accounts : Create a T-account for the Allowance for Doubtful Accounts and enter into it the amounts from the above schedule. Then write the T-account in equation format to prove that the above items account for the changes in the account. Record summary journal..
Create a pl-sql procedure - print out names of employees : Create a PL-SQL procedure that a company name, print out names of employees working at that company. Test your procedure with a company name you have in your company table.
Could you sit in a restaurant and eat by yourself : Can you be alone? Be honest! How long could you go without your phone, TV, the Internet, music, or even a book or magazine before you start to crawl out of your skin? Could you sit in a restaurant and eat by yourself
What is the mimimum expected payment government must make : Suppose the government seeks to find the best it can do (in terms of minimizing expected costs in a dominant strategy mechanism). What is the mimimum expected payment the government must make?
Explain your opinion on behaviorist treatment : After watching the video and reading this week's selections, indicate one specific area in the practice of psychology where behaviorist treatment is valid.
What is the psychological immune system : According to Dan Gilbert, what is Synthetic Happiness? What is the Psychological Immune System? How can it help us to deal with our Barriers? Summarize what Dan Gilbert is trying to prove

Reviews

Write a Review

Database Management System Questions & Answers

  Knowledge and data warehousing

Design a dimensional model for analysing Purchases for Adventure Works Cycles and implement it as cubes using SQL Server Analysis Services. The AdventureWorks OLTP sample database is the data source for you BI analysis.

  Design a database schema

Design a Database schema

  Entity-relationship diagram

Create an entity-relationship diagram and design accompanying table layout using sound relational modeling practices and concepts.

  Implement a database of courses and students for a school

Implement a database of courses and students for a school.

  Prepare the e-r diagram for the movie database

Energy in the home, personal energy use and home energy efficiency and Efficient use of ‘waste' heat and renewable heat sources

  Design relation schemas for the entire database

Design relation schemas for the entire database.

  Prepare the relational schema for database

Prepare the relational schema for database

  Data modeling and normalization

Data Modeling and Normalization

  Use cases perform a requirements analysis for the case study

Use Cases Perform a requirements analysis for the Case Study

  Knowledge and data warehousing

Knowledge and Data Warehousing

  Stack and queue data structure

Identify and explain the differences between a stack and a queue data structure

  Practice on topic of normalization

Practice on topic of Normalization

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd