ibm-midrangecontrol-language

How do you display SQL Select output from CL?


I am trying to replace an old CL program that issues RUNQRY command.

I can run the SQL statement from STRSQL and it will yield the same output as the query.

I tried RUNSQL and RUNSQLSTM but neither support just doing a SELECT

Is there a command to just display the output of SQL select?


Solution

  • Query Manager (STRQM) is the SQL based green screen replacement for Query/400. Manuals can be found here: Query Manager Use and Query Management Programming

    Queries can be created via a Query/400 like "prompted mode" or simply by entering SQL directly.

    Once a QM query has been defined, the Start Query Management Query (STRQMQRY) command can be used in CL to run it and includes an OUTPUT parameter that can be * (to display), *PRINT, or *OUTFILE.

    Another Option
    The QSHELL Db2 utility

    STRQSH CMD('db2 ''select table_name, table_owner from qsys2.systables limit 1''')
    

    Make sure that the environment variable QIBM_QSH_CMD_OUTPUT doesn't exist with a value of NONE and you'll get a Press ENTER to end terminal session. message at the bottom of your results.