Querying your database by running SQL scripts

You can create, edit, run, and troubleshoot scripts of SQL statements in the Run SQL Scripts window of System i® Navigator. When you finish working with the scripts, you can save the statements to your PC.

To open the Run SQL Scripts window, expand the system name and Databases and right-click the database to which you want to connect.

You can use the Examples list to build your scripts, manually create your statement, retrieve the SQL for an existing object using the generate SQL function, or build a script using SQL Assist.

You can check the syntax of your SQL by clicking Check Syntax. Additional ways of debugging your programs and scripts include debugging messages in the job log and starting IBM® i Debugger. When syntax checking is complete, you can save the script by selecting Save from the File menu.

To run an SQL script, select one of the following options from the Run menu:

The results are added to the end of the Messages tab. If the Smart Statement Selection option on the Options menu is not checked, the text that is selected is run as a single SQL statement.