Hi Peter,
> Can someone please instruct me as to how I can output a DESCRIBEd value of a
> table in DBI?
DESCRIBE is a command written especially for SQL*Plus, and is not a standard
SQL command. To get something similar to DESCRIBE in raw SQL, you'll have to
write some code which accesses the Oracle data dictionary (which is all the
DESCRIBE program does itself, probably). The following primitive code might
get you started, though it only covers "real" tables. To get something to
cover synonyms and views, you might want to modify and wrap this within some
PL/SQL using DBMS_OUTPUT and add some other stuff to get other objects other
than straight tables:
select COLUMN_NAME "Name"
,DECODE(NULLABLE,'Y','','N','NOT NULL') "Null"
,SUBSTR(DECODE(DATA_TYPE,'CHAR',
'CHAR('||TO_CHAR(DATA_LENGTH)||')'
,'VARCHAR2','VARCHAR2('||
TO_CHAR(DATA_LENGTH)||')'
,'NUMBER','NUMBER('||
TO_CHAR(DATA_PRECISION)||
','||TO_CHAR(DATA_SCALE)||')'
,DATA_TYPE),1,30) "Type"
from user_tab_columns
where table_name = 'MY_TABLE'
order by COLUMN_ID
/
Once you've wrapped this within some PL/SQL (or created some views?), you'll
then be able to do something in SQL*Plus like:
execute my_desc('MY_TABLE');
Within DBI, use the special 'func' methods available within DBD::Oracle
(documented within the DBD::Oracle distribution), to get the output too.
Good luck! :-)
Rgds,
AndyD
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/