Your colleague, John, has been struggling with a PL/SQL query that should display the Customer ID and the House Number, including the Materials used in the construction of the townhouses. John doesn’t seem to be able to determine why the query is not working and has asked for your assistance. Identify the errors and re‐write the correct code: set serveroutput on
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.
Your colleague, John, has been struggling with a PL/SQL query that should display the Customer ID and the House Number, including the Materials used in the construction of the townhouses. John doesn’t seem to be able to determine why the query is not working and has asked for your
assistance.
Identify the errors and re‐write the correct code:
set serveroutput on
c_id CUSTOMER.cust_id%Type;
t TOWNHOUSE.house_num%Type;
m_name MATERIALS.material_name%Type;
cursor info is
select cu.cust_id, t.house_num, m.material_name
from CUSTOMER cu, TOWNHOUSE t, MATERIALS m, PURCHASE_AGREEMENT pa
where cu.cust_id = pa.cust_id
and t.house_num = pa.house_num
and m.material_id = pa.material_id
begin
for rec in info
c_id:=rec.cust_id;
t:= rec.house_num;
m_name:=rec.material_name;
dbms_output_put_line('CUSTOMER ID: ' || c_id || ', ' || chr(13) ||'HOUSE NUM: ' || t ||
chr(13) || 'MATERIALS: ' || m_name);
dbms_output.put_line('‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐');
end loop;
Step by step
Solved in 2 steps with 1 images