1

I am trying to translate an Oracle query

SELECT name FROM emp START WITH name = 'Goyal' CONNECT BY PRIOR empid = mgrid

Getting error as unexpected token connect by.

pikas
  • 83
  • 7

3 Answers3

1

To find dependencies on an object, you could try DBMS_UTILITY.GET_DEPENDENCY

https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.db2.luw.apdv.sqlpl.doc/doc/r0055165.html

If you are just interested in table dependencies (but for all tables), this is just one of a number of examples out on the web https://datageek.blog/2015/05/07/db2-administrative-sql-cookbook-identifying-dependent-mqts-and-views/

Paul Vernon
  • 3,818
  • 1
  • 10
  • 23
1

That only ever works when ORACLE compatibility is on. Set it as follows, then rerun the query:

$ db2set DB2_COMPATIBILITY_VECTOR=08
$ db2stop
$ db2start
Tano Fotang
  • 449
  • 3
  • 7
0

Was your Db2 database created in Oracle Compatibility mode? If not, you won't have CONNECT BY support enabled. You can enable CONNECT BY independently of full Oracle support by setting the appropriate bit of the compatibility vector. https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.db2.luw.apdv.porting.doc/doc/r0052877.html

BTW you should use the SYSCAT catalog views rather than the SYSIBM catalog views DB2 Query to retrieve all table names for a given schema

Paul Vernon
  • 3,818
  • 1
  • 10
  • 23