Select count(*) from PL/SQL variable
<p>I am trying to wrote a PLSQL block that firstly..</p>

<p>grabs the table name from all_tables where rownum =1</p>

<p>I then want to assign this table_name to a variable.</p>

<p>I then want to count the number of rows of this table and print to the screen.</p>

<p>I have pasted my code below. Are you able to reference a variable withing a sql statement as i have?</p>

<pre><code>DECLARE
TABLE_HOLDER VARCHAR2(200);
COUNT_OF_ROWS NUMBER;

BEGIN

SELECT TABLE_NAME INTO TABLE_HOLDER FROM ALL_TABLES 
WHERE OWNER ='ROB1' AND ROWNUM=1;
DBMS_OUTPUT.PUT_LINE(TABLE_HOLDER);

SELECT COUNT(*) INTO COUNT_OF_ROWS FROM TABLE_HOLDER;
DBMS_OUTPUT.PUT_LINE(COUNT_OF_ROWS);
END;
</code></pre>

<p>Thanks.</p>