开发者

Return a 'DESC package' in PHP using OCI

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 开发者_C百科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


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';


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'


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜