Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask PL-SQL Expert

Using MySQL commands answer the questions listed below usingthe TinyVideoschema. Submit via the D2L dropbox the final SQL scripts for each problem. You must answer all parts of the question before receiving any partial credit. For example, do not expect any points if all you answer is part b of question 3. Each part builds upon the correct answer of the previous part.

Question 1.

a) Create a view called customer_with_balances that has the following columns: customer_number, customer_lname and customer_balance. The view should only include those customers where the customer balance is greater than zero.

b) Write the SELECT statement to show all records from the customer_with_balances view.

customer number      customer_lname        customer balance

102                            Dawson                    11.00

103                            Knight                      6.00

105                            Mcclain                     15.00

107                            Elliott                       5.00

109                            Ochoa                      10.00

111                            Mann                       8.00

112                            Trujillo                     3.00

Question 2.

a) Create a stored function called get_customer_balance which will return a customer's balance from the membership table by passing in a membership number.

b) Write a single SELECT statement to show the customer balance for member 102 by using the get_customer_balance function.

 

customer number      get_customer_balance

102                            11.00

Question 3.

a) Create a trigger called membership_balance_updates that will capture any updates made to the balance column in membership. The trigger should only capture those transactions in which the member's balance actually changes. The membership_id, old balance, new balance, user, transaction date should be placed into a membership_balance_audit table.
Use the following script to create the membership_balance_audit table.
CREATE TABLE IF NOT EXISTS

membership_balance_audit

(mem_num                   INTEGER,

 old_mem_balance     DECIMAL(10,2),

 new_mem_balance  DECIMAL(10,2),

 transaction_date       TIMESTAMP,

 transaction_user       VARCHAR(50));

b) Run the following update statements after the trigger has been created.

UPDATE membershipSET balance = 10.00WHERE membership_id = 104;

UPDATE membership SET first_name = 'Dan' WHERE membership_id = 103;

c) Write the SELECT statement to show all records in the membership_balance_audit table. (Note: The transaction date will be different for your result set.)

mem_num        old_mem_balance          new_mem_balance                 transaction_date            transaction_user

104                     0.00                               10.00                                     2012-04-1200:00:00     root@localhost

PL-SQL, Programming

  • Category:- PL-SQL
  • Reference No.:- M92036728
  • Price:- $100

Guranteed 48 Hours Delivery, In Price:- $100

Have any Question?


Related Questions in PL-SQL

Purpose of the assessment with ulo mapping the purpose of

Purpose of the assessment (with ULO Mapping) The purpose of this assignment is to develop skills in managing data in databases and to gain understanding of data model development and implementation using a commercially a ...

Continuing the project you have worked on in weeks 1-4 in

Continuing the project you have worked on in Weeks 1-4, in this final week, complete the following tasks: Refine your database and SQL statements by incorporating your instructor's feedback. Verify that the database comp ...

For this assignment you will be provided a database backup

For this assignment, you will be provided a database backup for a database called FinanceDB. You will have to restore this backup to your own version of SQL Server. All of the questions in this assignment relate to the F ...

Assignment - queries functions and triggersaimthe aims of

Assignment - Queries, Functions and Triggers Aim The aims of this assignment are to: formulate SQL queries; populate an RDBMS with a real dataset, and analyse the data; design test data for testing SQL queries; create SQ ...

Complete the following tasksin microsoft access create the

Complete the following tasks: In Microsoft Access, create the database and tables that you identified in W3 Assignment 2. In Microsoft Word, write the SQL statements to create the database and tables. Write SQL statement ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As