Link to home
Start Free TrialLog in
Avatar of Ari_Weil
Ari_Weil

asked on

Equivalent to PATINDEX in DB2

I am writing a series of maintenance scripts to execute Runstats, generate various scripts, etc.  One of the scripts is to retrieve all foreign key associates from and to a particular table.  The db2look .out command is fine for finding the foreign keys FROM the table in question, but it falls short for foreign keys TO that table.  So I've got a script that queries the sysrels table via a formatted select statement, but I'm having to then take that script and either modify it by hand, or insert it into a SQL Server maintenance db I have and use PATINDEX there (I'd like to cut out the extra step if possible).  The problem is in the way the sysrels table keeps track of the PKCOLNAMES and PKCOLNAMES, they're listed and padded with spaces between the names, so there's nothing that I'm aware of in DB2, save a massive, complicated script using the LENGTH function on every column in the table in question, that will delimit the column names with spaces.  Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of Sumeet_db2
Sumeet_db2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial