1-6. Displaying Results in SQL*Plus
Problem
You want to display query results at the SQL*Plus prompt.
Solution
Use the DBMS_OUTPUT
package to assist in displaying query results or lines of text. The following example depicts both of these use cases:
DECLARE
first VARCHAR2(20);
last VARCHAR2(25);
BEGIN
SELECT first_name, last_name
INTO first, last
FROM employees
WHERE email = 'VJONES';
DBMS_OUTPUT.PUT_LINE('The following employee matches your query:');
DBMS_OUTPUT.PUT_LINE(first || ' ' || last);
END;
The previous example uses DBMS_OUTPUT.PUT_LINE
to print a line of text as well as the values of the variables first
and last
.
How It Works
The DBMS_OUTPUT
package contains several useful procedures. ...
Get Oracle and PL/SQL Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.