Oracle Reference to Table_Name, Column_Name, etc by reference to variable

pts.
Tags:
Oracle
Oracle 8i
Oracle development
SQL
Does Oracle prohibit reference to Table_Name, Column_Name, etc by reference to a declared variable? I am trying to create a simple routine to print documentation whenever any changes are made to the database using the following routine: DECLARE CURSOR Table_cursor is SELECT * FROM TABS WHERE table_name like upper('c%') or table_name like upper('t%') or table_name like upper('v%'); v_cursor Table_cursor%ROWTYPE; v_tablename varchar2(30) := ''; BEGIN OPEN table_cursor; LOOP FETCH table_cursor INTO v_cursor; EXIT WHEN table_cursor%NOTFOUND; v_tablename := v_cursor.table_name; DBMS_OUTPUT.PUT_LINE(v_tablename); DESCRIBE v_tablename; END LOOP; END; / The problem is in the line DESCRIBE v_tablename. If I remove this line, the printed output is exactly as I want. I then want to use that list to print table definitions and do this dynamically so I can update documentation whenever a table is changed.

Answer Wiki

Thanks. We'll let you know when a new response is added.

You could use a SELECT from ALL_TAB_COLUMNS instead of a DESCRIBE.

For example, a cursor based on the following select:

<pre>select column_name,data_type,data_length,data_precision,nullable
from all_Tab_columns
where table_name = v_tablename;</pre>

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following