Editing and Testing Procedures

 


Clicking on the Procedure Editor tab brings the editor window into focus as shown below . The procedure editor has the ability to record keystroke macros and many of the advanced editing features found in the SQL Editor.

In addition to the editing function found in the SQL Editor, the Procedure Editor supports prompting for scalar functions. If you are typing an SQL function into the procedure editor, SQLThing will prompt you with the arguments to the function. The scalar function list is current as of V5R1 and can be modified and extended by you to incorporate your own user defined functions, (see the appendix for details).

Also, the Formula Helper window contains many syntax skeletons for procedure grammar. Use the tools menu to load the formula helper and select the Syntax Skeletons option from the drop down list. Skeletons for popular procedure grammar can be loaded into the formula window and then dragged into the SQLThing Procedure Editor.

Note that you can also access syntax skeletons and functions by pressing the CTRL+Space Bar key combination.  This causes SQLThing to display a list of available skeletons and functions.  Choosing a function or skeleton from the list causes the code to be pasted into SQLThing.

Once you are finished creating your procedure, SQLThing can take care of compilation of the PSM procedure and retrieval of the C source code generated by the AS/400. To compile a procedure, select the Procedure menu and then select Compile. This causes SQLThing to create a source physical file on your AS/400 in the QTEMP library. SQLThing then moves the procedure code into the source physical file and calls RUNSQLSTM to compile the stored procedure. If the compilation is successful, you are prompted to retrieve the C code. If you elect to retrieve the C source code, it will be placed in SQLThing generic code editor windows.

Testing Procedures

When you are using the Procedure List tab, the Test menu item under the Procedures menu becomes available.  This item causes SQLThing to execute the currently highlighted procedure.  At this time, you have a choice of whether to view the parameter results of a procedure call or to view the result set produced by the procedure.  A future version of SQLThing will allow you to see parameter changes and to view result sets in on call to the test window.