3rd Annual Plex/2E Worldwide Users Conference 5D – Advanced Search for Plex RPG Using SQL Mark...
-
Upload
dulcie-lane -
Category
Documents
-
view
217 -
download
0
Transcript of 3rd Annual Plex/2E Worldwide Users Conference 5D – Advanced Search for Plex RPG Using SQL Mark...
3rd Annual Plex/2E Worldwide Users
Conference
5D – Advanced Search for Plex RPG Using SQL
Mark Murphy
STAR Base Consulting, Inc.
2 8/20/2007 Advanced Search for Plex RPG using SQL
Bio
> Mark Murphy
> STAR BASE Consulting, Inc.
> Cincinnati, OH
> Started with AS/400 and 2E in 1989
> Using Plex since 1997
> Experience in Warehousing, Distribution, Retail, Manufacturing and Business Services markets
3 8/20/2007 Advanced Search for Plex RPG using SQL
Overview
Scenario: You have been asked to build a Customer Inquiry function that will sort customers by Customer ID, or Name. In addition it needs to be able to filter the customer records based on a portion of the Name, the State, or Zip Code. The environment for this inquiry function is iSeries.
The Problem: While this would be a good task for a custom SQL query, the Plex generators will not embed SQL within RPG.
The Approach: Using a little source code and language SQLRPG we can build a function that executes a custom SQL Select as part of a Block Fetch.
4 8/20/2007 Advanced Search for Plex RPG using SQL
Components
> There are just a few components needed An SqlBlockFetch function
Some User Source to embed the SQL in RPG
A function to build the SQL statement
A few messages to contain the static portion of the SQL
5 8/20/2007 Advanced Search for Plex RPG using SQL
SQLBlockFetch
6 8/20/2007 Advanced Search for Plex RPG using SQL
User Source
> There are 7 necessary User Sources Declare Variables
Declare SQL Statement
Declare Cursor
Prepare Statement
Open Cursor
Close Cursor
Fetch
7 8/20/2007 Advanced Search for Plex RPG using SQL
User Source – DeclareVariables
8 8/20/2007 Advanced Search for Plex RPG using SQL
User Source – DeclareSqlStatement
9 8/20/2007 Advanced Search for Plex RPG using SQL
User Source – Declare Cursor
10 8/20/2007 Advanced Search for Plex RPG using SQL
User Source - PrepareStatement
11 8/20/2007 Advanced Search for Plex RPG using SQL
User Source - OpenCursor
12 8/20/2007 Advanced Search for Plex RPG using SQL
User Source - CloseCursor
13 8/20/2007 Advanced Search for Plex RPG using SQL
User Source - Fetch
14 8/20/2007 Advanced Search for Plex RPG using SQL
SQL Block Fetch
> Data Access gives us the processing shell
> Only three places to add code Initialization
Position
Fetch
15 8/20/2007 Advanced Search for Plex RPG using SQL
SQLBlockFetch - Initialize
16 8/20/2007 Advanced Search for Plex RPG using SQL
SQLBlockFetch - Position
17 8/20/2007 Advanced Search for Plex RPG using SQL
SQLBlockFetch - Position
18 8/20/2007 Advanced Search for Plex RPG using SQL
SQLBlockFetch - Fetch
19 8/20/2007 Advanced Search for Plex RPG using SQL
SQLBlockFetch - Fetch
20 8/20/2007 Advanced Search for Plex RPG using SQL
Tying It All Together
> Two things left Replace BlockFetch with SQLBlockFetch in grid function
Add a function to build your SQL Statement
21 8/20/2007 Advanced Search for Plex RPG using SQL
Function Replacement
22 8/20/2007 Advanced Search for Plex RPG using SQL
The Action Diagram
23 8/20/2007 Advanced Search for Plex RPG using SQL
The Action Diagram – Part 2
24 8/20/2007 Advanced Search for Plex RPG using SQL
One Way to build the SQL Statement
25 8/20/2007 Advanced Search for Plex RPG using SQL
Resources
E-mail: [email protected]
Phone: (513) 245-0400
The Edge: edgeusergroup.pugmarks.net
Plex Wiki: wiki.plexinfo.net
2E Wiki: wiki.2einfo.net
26 8/20/2007 Advanced Search for Plex RPG using SQL
Synopsis
SQL support for iSeries development in Plex, and for that matter 2E is limited at best, and designing reports that perform acceptably can be a daunting task when the requirements are complex. This framework provides a way to easily develop high performance reports for your iSeries without the need for creating a lot of extra access paths to support your reports.