Transcript Document
IBM Software Group / DB2 Information Management
Informix 4GL and EGL
Jerry Keesee, Director of the Informix lab
S. Venkatesh Gopal, Development, Informix R&D
© 2005 IBM Corporation
IBM Software Group / DB2 Information
Management
Disclosure Information
PLANS ARE SUBJECT TO CHANGE OR
CANCELLATION WITHOUT NOTICE
2
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Agenda
Informix 4GL Today
Why EGL?
Overview of some EGL capabilities
4GL / EGL Syntax Comparison
JSF & EGL – Web Application Development
Overview
Conversion of 4GL to EGL
3
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Current I4GL Development/Runtime Environment
A well established development environment.
Can be deployed as either pseudo-code (P code)
or C code applications
– P code primarily is used for development – debugger works
with P code only
– most develop with P code and deploy with C code
Connectivity to Informix database servers only
– unless an Informix Gateway server is added
Small disk/memory footprint delivers very good
runtime performance
Wide platform coverage.
4
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Primary Requirements for I4GL
Provide application database connectivity to IDS & DB2
Provide a modern integrated development environment
Provide the capability to create modern applications with:
– graphical user interfaces
– and character-based user interfaces
Maintain and grow user base
– enhancements should “fit” existing users
– and be compelling for new ones…
5
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
EGL
A language as easy as I4GL to use and develop with.
Provides an industry standard IDE (Rational Application developer)
for developing EGL, Java, Web and COBOL applications.
Provides an enriched set of the same capabilities.
– Text user interface (Curses based).
– Calls to “C” functions.
– SQL (embedded, dynamic and more).
– Interactive debugging capability.
– Powerful reporting capability.
– Command line based application development.
– Data types (all of I4GL and some more in addition).
6
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
EGL .....
In addition to the I4GL feature set provides
– Development and runtime capabilities for Windows platforms.
– More general programming capabilities.
– Web Application development and deployment.
• Same business logic can be shared in both deployments.
– Multiple Database connectivity.
• Uses JDBC and allows to connect to any DB.
–
–
–
–
Service Oriented Architecture (Web Services).
MQ Access.
File I/O
Provides for COBOL generation options (deployable in i-Series and zSeries).
– Calling out Java code from EGL.
– and more…
7
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
EGL (similarities to I4GL).
Lots of similarities.
– Basic statements and looping constructs are similar.
– SQL statements are similar to 4GL (prepare, execute,
open, get (fetch), close and for each).
– Text user interface similar (with a more general
programming model) to I4GL with extended capabilities.
– Reporting framework provides for a wider set of output
formats (PDF, Text, XML, CSV, HTML).
– A highly interactive and visual debugging environment
based on the Eclipse framework.
8
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Examples (Comparing I4GL to EGL).
DEFINE INTVAL INTEGER
INTVAL INT;
DEFINE myRecord RECORD
Record myRecordType
intval INTEGER,
intval int;
floatval FLOAT,
floatval float;
decimalval DECIMAL
decimalval decimal;
END RECORD
End
myRecord myRecordType;
myotherRecord myRecordType;
9
LET intval = 10
intval = 10;
LET myrecord.intval = 10
myRecord.intval = 10;
CALL funcName(param1,param2)
funcName(param1,param2);
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Examples (Comparing I4GL to EGL).
while(i < 10)
let i = i + 1
while(i < 10)
i = i+1;
end while
End
case (i)
case(i)
when 10
when (10)
…
when 20
…
when (20)
…
otherwise
…
otherwise
…
End case
10
© 2005 IBM Corporation
…
end
February 2, 2005
IBM Software Group / DB2 Information
Management
Examples (SQL in I4GL compared to EGL)
11
insert into mytable (code, quantity)
values (‘abc’, 10)
execute #sql{
prepare stmtid from "select
fname,lname from customer where
customer_num=10"
prepare stmtid from "select
fname,lname from customer where
customer_num=10";
declare secondSet cursor for select
fname,lname from customer
open secondSet
open secondSet
#sql{select fname,lname from
customer };
fetch secondset into fname,lname;
get next from secondSet into
fname,lname;
© 2005 IBM Corporation
insert into mytable(code,quantity)
values('abc',10)};
with
February 2, 2005
IBM Software Group / DB2 Information
Management
Some Infrastructure differences…
EGL being IDE based requires knowledge of
Eclipse Workspace paradigms.
Everything exists in a workspace
– Workspace has projects.
• Projects have packages.
– Packages have files.
– Files can be either EGL source files, EGL programs or EGL libraries.
A program is equivalent to a I4GL file having the
main function.
A library is equivalent to any I4GL modules that
provides functions for use by other I4GL modules
or I4GL globals file.
12
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Informix 4GL Today
EGL Today
PACKAGE PlayerStatsApplication;
DATABASE stats
import InfxDbSchema.sports.stats.*;
GLOBALS
DEFINE player_bats RECORD LIKE informix.atbats.*
DEFINE batting_ave RECORD LIKE informix.battingaverage.*
END GLOBALS
-----------------------------------------MAIN
-----------------------------------------DEFINE BA DECIMAL (4,3)
DECLARE curs_at_bats cursor for select * from informix.atbats
OPEN curs_at_bats
WHILE (SQLCA.SQLCODE = 0)
FETCH curs_at_bats into player_bats.*
IF (SQLCA.SQLCODE = 100) THEN
EXIT WHILE
END IF
CALL compute_BA(player_bats.atbats, player_bats.hits) RETURNING BA
INSERT INTO informix.battingaverage VALUES (player_bats.lname, BA);
END WHILE
COMMIT WORK
CLOSE curs_at_bats
END MAIN
PROGRAM player_main
use player_ba;
player_bats rec_like_informix_atbats;
batting_ave rec_like_informix_battingaverage;
FUNCTION main()
BA DECIMAL (4,3);
PREPARE $_STMT_curs_at_bats FROM "select * from informix.atbats";
open curs_at_bats with $_STMT_curs_at_bats;
WHILE (SQLCODE = 0)
get next from curs_at_bats into player_bats.lname, player_bats.atbats,
player_bats.hits, player_bats.walks;
IF (SQLCODE = 100)
EXIT WHILE;
END
BA = compute_BA(player_bats.atbats, player_bats.hits);
execute #sql{INSERT INTO informix.battingaverage VALUES (:player_bats.lname, :BA) };
END //WHILE
commit() ;
CLOSE curs_at_bats;
END // FUNCTION
END // PROGRAM
FUNCTION compute_BA(at_bats, hits)
DEFINE at_bats INTEGER
DEFINE hits INTEGER
DEFINE BA DECIMAL (4,3)
LET BA = hits/at_bats
RETURN BA
END FUNCTION
PACKAGE PlayerStatsApplication;
LIBRARY player_ba
FUNCTION compute_BA(at_bats INT IN, hits INT IN) returns (DECIMAL (4,3))
IDS
BA DECIMAL (4,3);
BA = hits/at_bats;
RETURN( BA);
END // FUNCTION
END // LIBRARY
13
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Compiling and running applications.
Set up the compilation options in the build
descriptor.
Generate to Java
Run the application.
Take the generate Java and deploy it to any other
machine with the runtime libraries.
If you have created a web application, deploy the
web archives to the test server or any J2EE server
from within the IDE.
14
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Some extended capabilities…
15
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Integrated development environment
An industry standard IDE
Based on the Eclipse framework
Provides for different development perspectives
– EGL
– EGL/Web
– Java and more.
Context Sensitive editor
Debugging capability (Interpretive debugger).
Page designer for JSPs and page handlers.
Code Assist (using Ctrl + Space)
16
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Records
Different types…
– Basic Records
– SQL Records
– Serial Records
– Indexed Records
– MQ Records.
Record type identifies the I/O that can be done
Same statements are used for different Record
types
No I/O with Basic records.
17
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Records
18
Operation
Serial
SQL
Indexed
MQ
add
insert record at end
of file
Insert record
insert record at key
send record to
queue
close
close file
close file
close file
close queue
delete
n/a
delete current
record
delete current
record
n/a
get (key)
n/a
record based on
key
record based on
key
n/a
get next
get next record
get next record
get next record
get next message
get previous
n/a
replace
n/a
© 2005 IBM Corporation
get previous record get previous record
replace current
record
replace current
record
February 2, 2005
n/a
n/a
IBM Software Group / DB2 Information
Management
Records (SQL Records)
Record definition
Record CustomerRecord type SQLRecord {tableNames=("customer") }
customer_num int {column=customer_num};
fname char(15) {column = fname};
lname char(15) {column = lname};
company char(20) {column = company};
address1 char(20) {column = address1};
address2 char(20) {column = address2};
city char(15) {column = city};
state char(2) {column = state};
zipcode char(5) {column = zipcode};
phone char(18) {column = phone};
end
A default SQL statement is generated for every SQLRecord
The SQL column information can be extracted using the IDE.
19
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
SQL Records (example)
mycustomer CustomerRecord;
myCustomerArray customerRecord[];
open resultSet
for mycustomer;
try
while(sqlcode = 0)
get next from resultSet;
//mycustomer.customer_num has the value.
if(sqlcode = 100)
exit while;
end
end
onException
End
get myCustomerArray;
20
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
File I/O using Records
Create a serialRecord.
Record FileRecord type serialRecord {filename="customer"}
customer_num num(10);
fname char(15);
lname char(15);
End
Create a Resource Association.
Write your code.
myfilerecord FileRecord;
myfilerecord.customer_num = 100;
myfilerecord.fname = “John”;
myfilerecord.lname = “Doe”;
add myfilerecord;
21
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Message Queue Access
Easy MQ handling.
– Create Record definitions.
Record myMQRecord type MQRecord { queueName = "mqRA" }
fname char(10);
lname char(10);
End
– Create a Resource Association between the queueName attribute and the MQ system.
– Write your code.
mqr myMQRecord;
mqr.fname="Venkatesh";
mqr.lname="Gopal";
add mqr;
get mqr;
– Take full advantage using a package called “MQReusableParts”, a part of your
standard distribution.
22
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Web Development with EGL.
Sun PetStore Reference Application:
Hand-Coded
in Java IDE
MDD Competitor
WebSphere Studio
JSF & EGL*
507.5 Hours
330 Hours
55 Hours
*Internal Study
23
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Web Development using JSF
JSF is a J2EE Web UI / programming framework
User interface component model - Set of standard
widgets
Specification allows creation of custom UI
components
Event handlers to process client-driven events
Actions to call business logic
Validation framework to allow server side
validation
Internationalization/Localization
24
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
How do JSF and EGL fit together?
Controller
JSF
Request
Model
EGL
Servlet
(Faces Servlet)
EGL
Invokes
Response
JSP
(View)
25
© 2005 IBM Corporation
February 2, 2005
EGL
IBM Software Group / DB2 Information
Management
How do JSF and EGL fit together?
A perspective (EGL Web) that allows users to create a view (JSP)
containing standard controls and widgets.
Easy Drag and Drop to bind the data components to presentation
items in the view.
Automatic creation of a page handler that implements the controller
– Has an onPageLoad function, which is invoked the first time the web
page is rendered.
– A set of event handlers, each of which is invoked in response to a
specific user action (like clicking on a button or a link).
– Validation functions to validate web-page input fields.
Page handler can call other EGL library functions that implement the
actual business logic.
Data can be passed between pages using simple EGL statements.
26
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Taking your applications from 4GL to EGL
27
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
What is the Conversion Strategy?
Goal is to convert an I4GL application to the equivalent EGL application that
uses:
– the same display device
– the same database server
– I4GL TUI applications will be converted to EGL TUI applications
Convert, on a program-by-program basis, using the conversion utilities:
– provided as part of the IDE
– also available from the command line
Separate conversion passes required for:
– database metadata extraction
– shared libraries (C code or combination of C and I4GL code)
– I4GL source code
Automated conversion should convert most 4GL source code
– but, some 4GL programs may require manual intervention
28
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Conversion Assumptions
I4GL code is “legal”
– it will compile with I4GL 7.32 compiler
– conversion will not “fix” invalid I4GL code
Multiple passes are required
Functions that can not be resolved during
conversion are assumed to be C code functions
– if function is later found to be an I4GL function, re-conversion
would be required
C code functions do not use undocumented I4GL
internal functions
29
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
How is this Going to be Done?
WebSphere Studio conversion plug-in
– runs within the EGL development environment (Windows or
Linux)
• I4GL source directories can be mounted from current environments
• or copied to the EGL development environment
– GUI wizard collects information about I4GL source environment:
•
•
•
•
I4GL source and EGL destination directories
I4GL source files (.4gl, .per, .c, .so, message files, etc)
database connection information
locale information
– generates configuration XML files
– invokes the conversion utility
• displays conversion log upon completion
30
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
How is this Going to be Done?
Command line conversion utility
– Java program can be run in current I4GL build environments
• perhaps via current makefiles
– requires XML configuration file describing current 4GL
environment:
• could be generated using the IDE plugin
• or generated via shell script
– generates EGL conversion “projects” containing
•
•
•
•
31
database meta data
makefiles to re-link C code with new EGL stack library
EGL source files
report designs and other reporting artifacts
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Conversion Artifacts
Configuration file
– XML file generated from interaction with conversion wizard
– contains required conversion project information
Manifest file
– XML file generated during conversion of shared libraries
– contains declaration and usage information about each of the functions
(C and I4GL) used in the shared library
– used to resolve function declarations in dependent I4GL shared libraries
– required for subsequent I4GL source code conversions
Log file
– contains warnings and errors
– status of each source file
– summary of conversion
32
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Order of Conversion is Important!
Database metadata
– conversion creates EGL packages for each database used in the
project
– schema metadata will become a separate EGL project which
can be referenced by other EGL projects
Shared libraries
– conversion generates Manifest file and makefile
I4GL source files
– .4gl files
– .per (form) files
– message files
33
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Pre-Conversion Tasks
Identify & locate all the components of the 4GL
application to be converted
– (.4gl, .per, message files, shared libraries)
Identify connection information for each database
used
Start Informix database instances
Mount/copy source code to EGL development
machine, if required
Determine destination directory for converted EGL
source code & conversion artifacts
Identify “Client” locale – used to convert message
files
34
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Conversion Utility Processing
Map all I4GL constructs into equivalent EGL constructs
Convert existing “.4gl” source files into “.egl” source files
Convert existing “.per” form specification files into “.egl” TUI specification files
– No special file extensions for EGL form definitions
Migrate existing I4GL error message files into EGL error messages
Convert existing I4GL reporting logic into equivalent EGL reporting logic
Generate a “makefile” that will be used to link the C shared libraries to the
converted EGL project
– makefile will have targets for different operating systems
Report all warnings and errors
Generate log file to indicate the status of conversion
Create default EGL build descriptor file for the project
35
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Conversion tool within the IDE….
36
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Conversion tool…
37
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Conversion tool….
38
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Conversion tool (artifacts)…
39
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Conversion tool (conversion log).
40
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Post-Conversion Tasks
Review log file
Fix identified problems
– on the 4GL side and re-convert or
– in the new EGL file
– shared libraries may have to be re-converted if functions cannot be
resolved
Open the project in the IDE
Verify EGL packages and source files
View/update EGL build descriptor file
“Generate” Java code for the project
– fix problems in the EGL code
Set runtime properties from existing environment variables
Launch new EGL project
41
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Conversion Limitations
Database connections cannot be shared between
EGL and C code
C code cannot call EGL functions
Default values set in syscolval table are not
accessed
I4GL Dynamic Arrays (7.32 release) will not be
converted in initial release
42
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
Typical I4GL Program … Becomes Typical EGL Program
form.per
BL
BL
BL
main.4gl
C functions
BL
c_code.so
inventory.4gl
catalog.4gl
Text
IDS
Reports
I4GL to EGL Conversion
C functions
Text
Reports
SchemaLib.egl
BL
BL
main.egl
form.egl
BL
BL
inventory.egl
catalog.egl
43
© 2005 IBM Corporation
February 2, 2005
c_code.so
IBM Software Group / DB2 Information
Management
Now What Can You Do With It …
Use your I4GL
Business
Logic in EGL
Web Services
Webmain.egl
Use your I4GL
Business Logic
in whatever
comes next!!!
Use your I4GL
Business
Logic with
Message
Queues
Webinventory.egl
DB2
HTML
Output
IDS
XML
Output
PDF
Output
C functions
Text
Reports
SchemaLib.egl
BL
BL
main.egl
BL
BL
inventory.egl
catalog.egl
44
© 2005 IBM Corporation
February 2, 2005
c_code.so
IBM Software Group / DB2 Information
Management
EGL Releases…
6.0 ega 12/3/2004, GA 1/7
fix001 ega 12/20/2004
(first release for Informix)
ifix003 ega 2/28/2005 (Release with conversion
tool available through Rational updater).
6.0.0.1 ega 4/8/2005 (Conversion tool available
through Rational updater)
45
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
EGL information
EGL site
http://www-128.ibm.com/developerworks/rational/products/egl/
EGL downloads
http://www-106.ibm.com/developerworks/rational/library/egldoc.html
46
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
http://www.ibm.com/software/data/informix
47
© 2005 IBM Corporation
February 2, 2005
IBM Software Group / DB2 Information
Management
48
© 2005 IBM Corporation
February 2, 2005