parser library‎ > ‎

external sql

You can supply a separate sql statement, such as a select from sysmaster, that infx will execute and parse the results.

syslocks.sql

As an example, I will use the infx status service to run a simple select statement on the sysmaster syslocks  infx looks for external sql files in /infx/local/sql/external. The files must be owner/group informix and have permissions 660.

Contents of SQL:

demo1@bobii:/home/informix>cat /infx/local/sql/external/syslocks.sql

select * from syslocks;

I reference the results of the SQL via a list variable, based on the name of the SQL file. In this example, it will be ext_syslocks. All the columns in the select are available as variables in the list. Make sure you alias any expressions so you have a column name to refer to the result with.

A sequence of select statements can be used, as long as all but the last one select into temp tables. Only one result set can be output.

To access the results of syslocks.sql

demo1@bobii:/home/informix>infx status list=ext_syslocks vars=dbsname+tabname+type
sysmaster  sysdatabases  S
sysmaster  sysdatabases  S
sysmaster  sysdatabases  S
sysmaster  sysdatabases  S
sysmaster  sysdatabases  S