php + unixODBC + DB2 + DESCRIBE = token not valid?

后端 未结 4 1334
渐次进展
渐次进展 2021-01-16 11:04

Code I am trying to run:

$query = \"DESCRIBE TABLE TABLENAME\";
$result = odbc_exec($h, $query);

The result:

PHP War

相关标签:
4条回答
  • 2021-01-16 11:36

    The iSeries flavor of DB2 does not support the SQL DESCRIBE statement. Instead, you have to query the system table:

    select * from qsys2.columns where table_schema = 'my_schema' and table_name = 'my_table'
    
    0 讨论(0)
  • 2021-01-16 11:36

    If you just need the column names try

    select * from <TABLE> where 0 = 1
    

    I don't know how to get the column types, indexes, keys, &c

    0 讨论(0)
  • 2021-01-16 11:46

    To me it looks like you need to provide a way for the statement to return a value "Valid tokens: INTO" tells me that. I haven't used DESCRIBE before, but I would imagine that it returns something.

    Interactive SQL doesn't allow the command so I can't really help you much further than that.

    BTW, add the iSeries tag to your question. You might get a few more answers that way.

    0 讨论(0)
  • 2021-01-16 11:52

    This statement can only be embedded in an application program. It is an executable statement that cannot be dynamically prepared. It must not be specified in Java.

    From the iSeries DB2 SQL Reference.

    0 讨论(0)
提交回复
热议问题