Nickon
Nickon

Reputation: 10156

Display table values for select in anonymous code block in Oracle

I'm looking for a working example for my problem and can't find the right one... I want to display my SELECT's output in PL/SQL Developer. How to do this in this piece of code:

BEGIN
   SELECT * FROM MyTable;
END;

How to diplay a grid with values?

Upvotes: 1

Views: 694

Answers (1)

Alex Poole
Alex Poole

Reputation: 191315

You can do this from a Test window (but not, as far as I'm aware, from an SQL windows or a Command window.

In your anonymous block, open your query as a cursor using a bind variable:

BEGIN
   OPEN :rc FOR
      SELECT * FROM MyTable;
END;

Then add a variable with the same name as the bind variable, without the leading colon, of type Cursor:

enter image description here

Then execute your block. When it has completed click the tiny ellipsis next to the variable (circled in red in the picture above). The cursor contents will be shown in an SQL window as a result set:

enter image description here

Upvotes: 1

Related Questions