IBM Support

Converting Query for i Queries to SQL

Troubleshooting


Problem

This document explains the various options to change Query for i queries to SQL.

Resolving The Problem

Most queries created using Query for i (Query/400) can be converted to an SQL equivalent query using the IBM® i5/OS® commands Retrieve Query Management Query (RTVQMQRY) or Start Query Management Query (STRQMQRY). An example of the usage of the RVTQMQRY command follows:

RTVQMQRY QMQRY(mylib/myqry) SRCFILE(mylib/qsqlsrc) ALWQRYDFN(*YES)

This command creates a source file member that can be used with the command CRTQMQRY to create a QMQRY object, which can be used with the STRQMQRY command.

The query can run directly with STRQMQRY, for example:

STRQMQRY QMQRY(mylib/myqry) OUTPUT(*) ALWQRYDFN(*YES)

Note: Not all aspects of a Query/400 query can convert to SQL. The i5/OS command ANZQRY can be used to verify if a Query/400 query will convert; if it does not convert, it shows why it does not convert.

Some examples of a Query/400 query that will not convert correctly follow:
o The use of a type 2 join will be converted to a regular join in SQL and not a left outer or type 2 join.
o Edit codes used in Query/400 will not convert.
o Using Print options will not convert.

 

Related Information

[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CQbAAM","label":"IBM i Db2-\u003EQuery\/400"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]

Historical Number

459765728

Document Information

More support for:
IBM i

Component:
IBM i Db2->Query/400

Software version:
All Versions

Operating system(s):
IBM i

Document number:
643471

Modified date:
04 December 2024

UID

nas8N1018853

Manage My Notification Subscriptions