A
A
Alexey2015-10-21 11:44:48
Oracle
Alexey, 2015-10-21 11:44:48

How to see the result of a query?

Sorry for the very stupid question. How to view the content of a request

declare
  V_StudentRecord students%ROWTYPE;
  V_Department classes.department%TYPE;
  V_Course  classes.course%TYPE;
begin
  select *  
    into v_StudentRecord
    from students
    where id = 1000;
    
  select department, course
    into v_Department, v_Course
    from classes
    where room_id = 99997;
end;


When launched, only PL/SQL procedure successfully completed is displayed on the screen.
And I would like to see the unloading

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Max, 2015-10-21
@MaxDukov

select *  
    from students
    where id = 1000;

 select department, course
    from classes
    where room_id = 99997;

A
Alexander, 2015-10-21
@drunking

It is also possible to display the result of the query in output, for this you need to wrap the select in a cursor, and then output the result to the output in a loop using the dbms_output.put_line ( ) procedure. But there is one point, the put_line() procedure takes data with the varchar2 type (or types converting to it) as input, so put_line() will have to enumerate all the cursor fields, and then concatenate them.
The result will be something like this:

begin
  for rStudent in (
         select S.Id, S.Name, S.Age
           from Students S
     ) loop
          dbms_output.put_line (rStudent.Id || ' ' || rStudent.Name || ' ' rStudent.Age);
       end loop;
end;

I
igaraev, 2015-10-30
@igaraev

set serveroutput on
dbms_output.put_line()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question