Search code examples
ibm-midrangeclrpg

AS400 RUNSQL to printer output


AS400 CL question:

Is it possible to use RUNSQL statement in batch CL program to generate a spool file for printing, like we can do with STRSQL + Shift F1 (Modify attributes)?

trying RUNSQL. I don't see any options to redirect output.


Solution

  • No.

    In fact RUNSQL doesn't even support the SELECT statement

    The following statements can be used by RUNSQL:

    • ALTER FUNCTION
    • ALTER MASK
    • ALTER PERMISSION
    • ALTER PROCEDURE
    • ALTER SEQUENCE
    • ALTER TABLE
    • ALTER TRIGGER
    • CALL
    • COMMENT
    • COMMIT
    • compound (dynamic)
    • CREATE ALIAS
    • CREATE FUNCTION
    • CREATE INDEX
    • CREATE MASK
    • CREATE PERMISSION
    • CREATE PROCEDURE
    • CREATE SCHEMA
    • CREATE SEQUENCE
    • CREATE TABLE
    • CREATE TRIGGER
    • CREATE TYPE
    • CREATE VARIABLE
    • CREATE VIEW
    • DECLARE GLOBAL TEMPORARY TABLE
    • DELETE
    • DROP
    • GRANT
    • INSERT
    • LABEL
    • MERGE
    • REFRESH TABLE
    • RELEASE SAVEPOINT
    • RENAME
    • REVOKE
    • ROLLBACK
    • SAVEPOINT
    • SET CURRENT DECFLOAT ROUNDING MODE
    • SET CURRENT DEGREE
    • SET CURRENT IMPLICIT XMLPARSE OPTION
    • SET CURRENT TEMPORAL SYSTEM_TIME
    • SET ENCRYPTION PASSWORD
    • SET PATH
    • SET SCHEMA
    • SET TRANSACTION
    • TRANSFER OWNERSHIP
    • TRUNCATE
    • UPDATE

    RUNSQL is designed to support DBA/DBE tasks, not reporting.

    If you have the interactive SQL facility available, via STRSQL, then you also have the Query Manager tooling. Use the STRQM command to get into the interactive version to define queries and their output forms. The prompted mode looks a lot like Query/400, aka WRKQRY. But QM is SQL based and you can create queries in non-prompted mode by entering an SQL statement.

    Once you've created a QM query, you can use the STRQMQRY command to run it from the command line or a CL program. Works fine for quick and dirty reports.

    Of course IBM, would prefer you get with the times use Web Query. It is a much nicer product and does support batch reporting. But I believe it's still extra cost and isn't what I would call a quick and dirty solution.