Question: write the SQL statement accroding to the below questions: added a column named as fine (numeric) in the transaction table. This is for storing the

write the SQL statement accroding to the below questions:

added a column named as fine (numeric) in the transaction table. This is for storing the amount of fine paid by the patron when a book is returned late.

Q1: Create a Procedure issueBook, where patron_id and book_id is taken as parameters.

issueBook(patron_id, book_id)

This function will run when the patron is coming to issue a book.

Steps:

Verify the patron_id in the patron table

Verify the book_id in the book table (not a reference book)

Insert the new row in transaction tale with

-patronid, book id, transactiondate as today, fine 0 and rating as 1.

The transaction_id should automatically generate using sequence

q2: Create another procedure returnBook(patron-Id, book_id)

Create a procedure that should take in patron_id and book_id as parameters. The procedure will calculate the amount of fine due on the book.

This procedure will run when the patron is coming back to return the book.

Steps:

Read the tuple with the patron_id and book_id with type=1. Check the transaction date. Add 7 to that. If todays date > calculated date, calculate the fine.

Now insert the new row in transaction tale with

-patronid, book id, transactiondate as today, fine as calculated and rating as 2.

The transaction_id should automatically generate using sequence.

q3: Convert returnBook into a function that will return the fine amount.

Q4: Create a procedure to display the details of all the books that have been issues in the month of February.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!