Create a stored procedure named sp_ListBookDetails()
SQL
SQL stands for Structured Query Language, is a form of communication that uses queries structured in a specific format to store, manage & retrieve data from a relational database.
Queries
A query is a type of computer programming language that is used to retrieve data from a database. Databases are useful in a variety of ways. They enable the retrieval of records or parts of records, as well as the performance of various calculations prior to displaying the results. A search query is one type of query that many people perform several times per day. A search query is executed every time you use a search engine to find something. When you press the Enter key, the keywords are sent to the search engine, where they are processed by an algorithm that retrieves related results from the search index. Your query's results are displayed on a search engine results page, or SER.
Create a stored procedure named sp_ListBookDetails().
CREATE OR REPLACE PROCEDURE sp_ListBookDetails(in_ISBN IN INTEGER)
AS
temp_BookTitle VARCHAR2(250);
temp_BookDescription VARCHAR(250);
temp_BookPrice NUMBER(12,2);
temp_BookReviews INTEGER;
temp_UserRating NUMBER(12,2);
temp_BookCategoryID INTEGER;
BEGIN
SELECT
Book_Title
,Book_Description
,Book_Price
,Book_Reviews
,User_Rating
,Book_Category_ID
INTO
temp_BookTitle
,temp_BookDescription
,temp_BookPrice
,temp_BookReviews
,temp_UserRating
,temp_BookCategoryID
FROM HOL_BOOKS
WHERE ISBN = in_ISBN;
-- Output the results
DBMS_Output.Put_Line('---------------------------------------------');
DBMS_Output.Put_Line('Here are the details for ISBN ' || in_ISBN);
DBMS_Output.Put_Line('');
DBMS_Output.Put_Line('Book Title: ' || temp_BookTitle);
DBMS_Output.Put_Line('Book Description: ' || temp_BookDescription);
DBMS_Output.Put_Line('Book Price: ' || temp_BookPrice);
DBMS_Output.Put_Line('Book Reviews: ' || temp_BookReviews);
DBMS_Output.Put_Line('Book User Rating: ' || temp_UserRating);
DBMS_Output.Put_Line('Book Category Code: ' || temp_BookCategoryID);
DBMS_Output.Put_Line('---------------------------------------------');
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_Output.Put_Line('Cannot find this ISBN in HOL_BOOKS: ' || in_ISBN);
END
begin
sp_ListBookDetails(1);
sp_ListBookDetails(23734);
end
begin
sp_ListBookDetails();
end



Trending now
This is a popular solution!
Step by step
Solved in 2 steps









