Question

Hi I am trying to get information on an Oracle package directly from PHP using OCI8:

$sql = 'DESC my_package';
$stmt = oci_parse($conn, $sql);
oci_execute($stmt);

this returns:

Warning: oci_execute() [function.oci-execute]: ORA-00900: invalid SQL statement in /oci8_test.php on line 16

I know the command works as I tried it in SQLPlus.

Does anyone know how to achieve this.

Thx

Was it helpful?

Solution 2

Thx for the replies, I think I have found my answer.

So for anyone who is interested, as Vincent said, I think to make it work you'll have to create your own 'DESC'. The Oracle View to use is 'user_arguments', you get the function/procedure names, argument names and types, argument position, etc...

Select * from user_arguments where package_name = 'my_package'

OTHER TIPS

DESC is a SQL Plus command.

I have been away from Oracle for a few years now, but look into the data dictionary. For example for tables you could do below. There must be something for Packages as well. DESC MY_TABLE

is equivalent to

SELECT 
column_name "Name", 
nullable "Null?",
concat(concat(concat(data_type,'('),data_length),')') "Type"
FROM user_tab_columns
WHERE table_name='TABLE_NAME_TO_DESCRIBE';

DESC is a SQL*Plus command, it won't work out of SQL*Plus. You can write your own DESC by querying the data dictionnary from any tool:

SQL> SELECT column_name, data_type, data_length,
  2         data_precision, data_scale, nullable
  3    FROM all_tab_columns
  4   WHERE table_name = 'T';


COLUMN_NAME  DATA_TYPE  DATA_LENGTH DATA_PRECISION DATA_SCALE NULLABLE
------------ ---------- ----------- -------------- ---------- --------
COLUMN1      CHAR                 6                           Y
COLUMN2      CHAR                 6                           Y
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top