download it
TRANSCRIPT
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation
Informix 4GL and EGL
Jerry Keesee, Director of the Informix labS. Venkatesh Gopal, Development, Informix R&D
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation2 February 2, 2005
Disclosure Information
PLANS ARE SUBJECT TO CHANGE OR CANCELLATION WITHOUT NOTICE
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation3 February 2, 2005
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
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation4 February 2, 2005
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.
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation5 February 2, 2005
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…
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation6 February 2, 2005
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).
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation7 February 2, 2005
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 z-Series).
– Calling out Java code from EGL.
– and more…
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation8 February 2, 2005
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.
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation9 February 2, 2005
Examples (Comparing I4GL to EGL).
DEFINE INTVAL INTEGER
DEFINE myRecord RECORD
intval INTEGER,
floatval FLOAT,
decimalval DECIMAL
END RECORD
LET intval = 10
LET myrecord.intval = 10
CALL funcName(param1,param2)
INTVAL INT;
Record myRecordType
intval int;
floatval float;
decimalval decimal;
End
myRecord myRecordType;
myotherRecord myRecordType;
intval = 10;
myRecord.intval = 10;
funcName(param1,param2);
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation10 February 2, 2005
Examples (Comparing I4GL to EGL).while(i < 10)
let i = i + 1
end while
case (i)
when 10
…
when 20
…
otherwise
…
End case
while(i < 10)
i = i+1;
End
case(i)
when (10)
…
when (20)
…
otherwise
…
end
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation11 February 2, 2005
Examples (SQL in I4GL compared to EGL)
insert into mytable (code, quantity) values (‘abc’, 10)
prepare stmtid from "select fname,lname from customer where customer_num=10"
declare secondSet cursor for select fname,lname from customer
open secondSet
fetch secondset into fname,lname;
execute #sql{
insert into mytable(code,quantity) values('abc',10)};
prepare stmtid from "select fname,lname from customer where customer_num=10";
open secondSet
with
#sql{select fname,lname from customer };
get next from secondSet into fname,lname;
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation12 February 2, 2005
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.
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation13 February 2, 2005
FUNCTION compute_BA(at_bats, hits) DEFINE at_bats INTEGER DEFINE hits INTEGER DEFINE BA DECIMAL (4,3)
LET BA = hits/at_bats RETURN BAEND FUNCTION
IDS
PACKAGE PlayerStatsApplication;
import InfxDbSchema.sports.stats.*;
PROGRAM player_mainuse 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
PACKAGE PlayerStatsApplication;
LIBRARY player_ba
FUNCTION compute_BA(at_bats INT IN, hits INT IN) returns (DECIMAL (4,3))
BA DECIMAL (4,3); BA = hits/at_bats; RETURN( BA); END // FUNCTION
END // LIBRARY
Informix 4GL TodayInformix 4GL Today EGL TodayEGL Today
DATABASE 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_batsEND MAIN
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation14 February 2, 2005
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.
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation15 February 2, 2005
Some extended capabilities…
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation16 February 2, 2005
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)
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation17 February 2, 2005
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.
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation18 February 2, 2005
Records
Operation Serial SQL Indexed MQ
addinsert record at end
of fileInsert record insert record at key
send record to queue
close close file close file close file close queue
delete n/adelete current
recorddelete current
recordn/a
get (key) n/arecord based on
keyrecord based on
keyn/a
get next get next record get next record get next record get next message
get previous n/a get previous record get previous record n/a
replace n/areplace current
recordreplace current
recordn/a
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation19 February 2, 2005
Records (SQL Records)
Record definitionRecord 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.
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation20 February 2, 2005
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;
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation21 February 2, 2005
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;
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation22 February 2, 2005
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.
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation23 February 2, 2005
Web Development with EGL.
Sun PetStore Reference Application:
Hand-Coded in Java IDE MDD Competitor
WebSphere StudioJSF & EGL*
507.5 Hours 330 Hours 55 Hours
*Internal Study
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation24 February 2, 2005
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
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation25 February 2, 2005
How do JSF and EGL fit together?
JSF
Servlet
(Faces Servlet)
JSP
(View)
Request
Response
Invokes
Controller
EGL
EGL
EGL
Model
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation26 February 2, 2005
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.
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation27 February 2, 2005
Taking your applications from 4GL to EGL
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation28 February 2, 2005
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
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation29 February 2, 2005
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
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation30 February 2, 2005
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
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation31 February 2, 2005
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
• database meta data
• makefiles to re-link C code with new EGL stack library
• EGL source files
• report designs and other reporting artifacts
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation32 February 2, 2005
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
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation33 February 2, 2005
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
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation34 February 2, 2005
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
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation35 February 2, 2005
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
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation36 February 2, 2005
Conversion tool within the IDE….
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation37 February 2, 2005
Conversion tool…
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation38 February 2, 2005
Conversion tool….
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation39 February 2, 2005
Conversion tool (artifacts)…
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation40 February 2, 2005
Conversion tool (conversion log).
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation41 February 2, 2005
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
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation42 February 2, 2005
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
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation43 February 2, 2005
main.4gl
BL
inventory.4gl
BL
catalog.4gl
BL
BL
IDSText
Reports
c_code.so
C functions
main.egl
BL
inventory.egl
BL
catalog.egl
BL
BLSchemaLib.egl
c_code.so
C functionsText
Reports
I4GL to EGL Conversion
Typical I4GL Program … Becomes Typical EGL Program
form.per
form.egl
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation44 February 2, 2005
IDSDB2
main.egl
BL
inventory.egl
BL
catalog.egl
BL
BL
SchemaLib.egl c_code.so
C functions
Text
Reports
PDF Output
HTML Output
XML Output
Webmain.egl
Webinventory.egl
Use your I4GL Business
Logic in EGL Web Services
Use your I4GL Business Logic with Message Queues
Use your I4GL Business Logic
in whatever comes next!!!
Now What Can You Do With It …
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation45 February 2, 2005
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)
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation46 February 2, 2005
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
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation47 February 2, 2005
http://www.ibm.com/software/data/informix
IBM Software Group / DB2 Information Management
© 2005 IBM Corporation48 February 2, 2005