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 iSeries™ 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 iSeries System 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.
- All: Run your SQL script from the beginning to the end. If an error occurs and the Stop on Error option is turned on, the program stops and the statement where the error occurred remains selected.
- From Selected: Start your SQL script from the first statement that is selected or from the current cursor position to the end of the script.
- Selected: Run the statements that are selected.
- Stopping SQL scripts
You can stop or cancel a running SQL script from iSeries Navigator.
- Viewing the job log
The job log contains the messages that are related to your job. You can view the job log from iSeries Navigator.
- Generating SQL for existing objects
You can reconstruct the SQL that was used to create existing database objects in the Generate SQL window of iSeries Navigator.
- Building SQL statements with SQL Assist
You can build your SQL statements interactively with SQL Assist in iSeries Navigator. SQL Assist can help you build SELECT, INSERT, UPDATE, and DELETE statements.
- Starting iSeries System Debugger
iSeries System Debugger provides a graphical user debugging environment on your system. You can use iSeries System Debugger to debug and test programs that run on your system, including the programs that run in i5/OS® Portable Application Solutions Environment (PASE).
Parent topic:
iSeries Navigator database tasks
Related tasks
Creating a view that combines data from multiple tables
Using interactive SQL