Finding yourself among many

If you work in an environment with many iSeries servers, it might be necessary to embed the system name in an SQL query.  Fortunately, IBM provides a system table called “LOCATIONS”.  If you query this table and limit your search to only return the “local” entry, the system will tell you where you are.

SELECT CAST(CATALOG_NAME AS CHAR(12)) as SERVER
FROM qsys2/LOCATIONS
WHERE CATALOG_TYPE = 'LOCAL
FOR READ ONLY

This way, if youíre outputting SQL results to a local table, you can have a column to indicate where the data came from without changing a literal.

Comments are closed.