LINE NUMBER Create or replace Function House Detailsh_num in townhouse.house_num%Type) RETURN varchar2 IS detoils varchar(100); cursor ci is select c.cust_id ||;R'||t.build_price ||:'Il pa.purchase_date ||,'Il po.purchase_amt from CUSTOMER C, TOWNHOUSE L, PURCHASE_AGREEMENT pa where c.cust_id pa.cust_id

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter9: Working With Text Functions And Creating Custom Formats
Section: Chapter Questions
Problem 1.7CP
icon
Related questions
Question

Defend the use of a function instead of a procedure using examples from the query.

Review the code below then answer the questions that follow.
LINE
NUMBER
1
Create or replace Function House_Details(h_num in townhouse.house_num%Type)
2
RETURN vorchar2
3
IS
4
details varchar(100);
5
cursor c1 is
select c.cust_id ||R'|| t.build_price ||,'Il pa.purchase_date ||'Il pa.purchase_amt
6
from CUSTOMER C, TOWNHOUSE t, PURCHASE_AGREEMENT pa
where c.cust_id = pa.cust_id
and t.house_num = pa.house_num
10
and t.house_num = h_num;
11
BEGIN
12
open c1;
13
fetch cl into details;
14
if c1%notfound then
15
details := 'No house information found;
16
end if:
17
RETURN details;
18
close c1;
19
EXCEPTION
20
WHEN OTHERS THEN
21
raise_application_error(-20001, 'An error was encountered - '||SQLCODE||'-ERROR-
22
'1/SQLERRM);
23
END;
24
25
select House_Details(3) from dual;
Transcribed Image Text:Review the code below then answer the questions that follow. LINE NUMBER 1 Create or replace Function House_Details(h_num in townhouse.house_num%Type) 2 RETURN vorchar2 3 IS 4 details varchar(100); 5 cursor c1 is select c.cust_id ||R'|| t.build_price ||,'Il pa.purchase_date ||'Il pa.purchase_amt 6 from CUSTOMER C, TOWNHOUSE t, PURCHASE_AGREEMENT pa where c.cust_id = pa.cust_id and t.house_num = pa.house_num 10 and t.house_num = h_num; 11 BEGIN 12 open c1; 13 fetch cl into details; 14 if c1%notfound then 15 details := 'No house information found; 16 end if: 17 RETURN details; 18 close c1; 19 EXCEPTION 20 WHEN OTHERS THEN 21 raise_application_error(-20001, 'An error was encountered - '||SQLCODE||'-ERROR- 22 '1/SQLERRM); 23 END; 24 25 select House_Details(3) from dual;
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage