cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hello,

I try to get a description of the all the fields of an (external) oracle table but I'm no to happy yet.

"SELECT" to this oracle connection work but I can't use "DESC"-command successful.

The report looks like this:

REPORT z_desc_ext_table.
 
DATA: wa(500) TYPE c.
 
DATA: dbcon_name(30) TYPE c VALUE 'PDMQ' . "Name in DBCO
 
 
START-OF-SELECTION.
 
  EXEC SQL.
    SET CONNECTION :dbcon_name
  ENDEXEC.
  EXEC SQL.
    connect to :dbcon_name
  ENDEXEC.
 
 
  EXEC SQL.
    open c for
    desc table.in.oracle.
  ENDEXEC.
 
 
  DO.
    EXEC SQL.
      fetch next c into :wa
    ENDEXEC.
    IF sy-subrc  0.
      EXIT.
    ENDIF.
    WRITE: / wa.
  ENDDO.
 
 
  EXEC SQL.
    disconnect :dbcon_name
  ENDEXEC.

When the report is executed the following dump is produced:

...

Database error text........: "ORA-00900: invalid SQL statement"

Triggering SQL statement...: "FETCH NEXT "

Internal call code.........: "DBDS/NEW DSQL"

...

000300 DO.

000310 EXEC SQL.

fetch next c into :wa

000330 ENDEXEC.

000340 IF sy-subrc 0.

000350 EXIT.

000360 ENDIF.

...

Does anyone have an idea how to make this work?

0 Likes
View Entire Topic
Former Member
0 Likes

You can query dba_tab_columns, alternatively to desc <table>:

SQL> desc sapsr3.t000;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 MANDT                                     NOT NULL VARCHAR2(9)
 MTEXT                                     NOT NULL VARCHAR2(75)
...
 LOGSYS                                    NOT NULL VARCHAR2(30)

SQL> select column_name from dba_tab_columns where table_name = 'T000';

COLUMN_NAME
------------------------------
MANDT
MTEXT
....
LOGSYS

But off course you need to have permissions to query this oracle inventory view then.

Best regards

Michael