Informix Training

  • View
    1.868

  • Download
    6

Embed Size (px)

DESCRIPTION

basic Informix Training

Text of Informix Training

INFORMIX-4GL TRAINING

Kanbay Incorporated - All Rights Reserved

Versions of Informix-4GL Informix-4GL Rapid Development System (RDS) Informix-4GL C Compiler Version Compiling: Rapid Development System: Source file .4glPseudo code C Compiler System: Source .4gl->Intermediate fles->Executable file .4ge

| Kanbay Incorporated. All Rights Reserved

Differences b/w the two versions: RDS Compile Time Run Time Less More C Compiler More Less

| Kanbay Incorporated. All Rights Reserved

Basic Components of Informix 4GL PROGRAM MODULE FUNCTION FORM

| Kanbay Incorporated. All Rights Reserved

Program Blocks MAIN FUNCTION REPORT

| Kanbay Incorporated. All Rights Reserved

Compiling .4gl in RDS System Creating a program from a single module fglpc filename.4gl Creating a program from multiple modules Compile each program to p-code fglpc file1.4gl file2.4gl Concatenate p-code files together Cat file1.4go file2.4go >myprog.4gi Executing the program fglgo filename.4go OR fglgo myprog.4gi| Kanbay Incorporated. All Rights Reserved

Compiling .4gl in C Compiler version Creating a program from a single module C4gl filename.4gl o myprog.4ge Creating a program from multiple modules To compile a singe module to object code C4gl filename.4gl o filename.o To create an executable from multiple modules C4gl file1.4gl file2.o file3.0 o myprog.4ge Executing the program myprog.4ge

| Kanbay Incorporated. All Rights Reserved

Sample makefile 4GL = filename.4gl filename2.4gl FORM = formname.per PROG_NAME = application.4ge COBJS = $(4GL: .4gl=.o) POBJS = $(4GL:.4gl=.4go) FORM = $(FORM:.per=.frm) CCODE: $(OBJS) c4gl o $(PROG_NAME) $(COBJS) @-echo Finished Compiling ccode

| Kanbay Incorporated. All Rights Reserved

File ExtensionsExtension .4gl .4ge .o .4go .4gi .per .frm Description Informix 4GL source module C Compiled version executable C Compiled version object RDS Version object RDS Version executable Form File Source Form File Compiled

| Kanbay Incorporated. All Rights Reserved

DEFINING VARIABLESSYNTAX: DEFINE variablename data-type Example: DEFINE fname CHAR(10) DEFINE start_date DATE DEFINE x,y,z INTEGER (OR) DEFINE fname CHAR(10), start_date DATE, x,y,z INTEGER

| Kanbay Incorporated. All Rights Reserved

Initialization of VariablesLET: Assigns value to a variable. Example: LET fname = John Let x = 5 Initialize: INITIALIZE variables to NULLExample: INITIALIZE lname TO NULL

| Kanbay Incorporated. All Rights Reserved

Scope of VariablesGlobal Module LocalEXAMPLE:

glob.4glGLOBALS DEFINE var1 CHAR(1) END GLOBALS

emp_main.4gl GLOBALS Glob.4gl DEFINE var2 SMALLINT MAIN DEFINE var3 INTEGER CALL funct1() END MAIN FUCTION funct1() DEFINE var4 CHAR(1) END FUNCTION

Variable Scope var1 var2 Var3 var4 Global Module Local Local

| Kanbay Incorporated. All Rights Reserved

COMMENTS in 4GL A pair of hyphens or minus signs -- this is a comment The pound (or sharp) symbol # this is a comment Left and right braces { this comment is multi-line} Conditional comments --@ --#| Kanbay Incorporated. All Rights Reserved

Decision and Looping Statements IF CASE WHILE FOR

| Kanbay Incorporated. All Rights Reserved

Decisions: IF StatementSYNTAX:IF THEN .. ELSE . END IF

Example :IF var_name MATCHES [Yy] THEN ERROR Customer will be deleted. ELSE ERROR Delete cancelled. END IF.

| Kanbay Incorporated. All Rights Reserved

IF Within Other Statements Syntax:IF .THEN IF..THEN END IF END IF

EXAMPLE:IF state=IL THEN IF zipcode MATCHES 601* THEN ERROR City is Schaumburg END IF END IF

| Kanbay Incorporated. All Rights Reserved

Decisions: CASE statementSyntax: CASE WHEN {expr/Boolean-expr} statement.. [EXIT CASE] [OTHERWISE] statement. [EXIT CASE] END CASE Example: CASE WHEN answervar=Y MESSAGE Answered Yes. WHEN answervar=N MESSAGE Answered NO. OTHERWISE MESSAGE Bad Answer. END CASE.

| Kanbay Incorporated. All Rights Reserved

Logical Loop: WHILE Loop Syntax:WHILE Boolean expression statement(s). [EXIT WHILE] [CONTINUE WHILE].. END WHILE

EXAMPLE:WHILE boss_in_office = TRUE CALL act_busy() RETURNING boss_in_office END WHILE

| Kanbay Incorporated. All Rights Reserved

FOR LoopSyntax:FOR integer variable = integer expression to integer expression [STEP integer expression] statement [CONTINUE FOR]. [EXIT FOR]. END FOR

Example:DEFINE i SMALLINT FOR i=1 TO 10 DISPLAY i = , i AT i,1 END FOR

| Kanbay Incorporated. All Rights Reserved

SCREEN: The screen is the area of the terminal where you can display the information. Default size of the screen is 24*80 Informix -4GL allows you to break the screen area into smaller sections called windows.

| Kanbay Incorporated. All Rights Reserved

WINDOW OPEN WINDOW windowname AT screenparameters WITH no of rows ,no of columns [ATTRIBUTE(attribute-list)] Example: OPEN WINDOW w_yesno AT 10,10 WITH 4 ROWS,20 COLUMNS ATTRIBUTE (BORDER)

| Kanbay Incorporated. All Rights Reserved

Screen Interaction Statements ERROR DISPLAY MESSAGE PROMPT

| Kanbay Incorporated. All Rights Reserved

MESSAGE: Syntax: MESSAGE display-list [ATTRIBUTE(attribute-list)] Example: MESSAGE Press the first letter of an option. ATTRIBUTE (REVERSE) ATTRIBUTES: UNDERLINE BOLD DIM| Kanbay Incorporated. All Rights Reserved

REVERSE BLINK

INVISIBLE NORMAL

ERROR Syntax: ERROR display-list [ATTRIBUTE(attribute-list)] EXAMPLE: ERROR No Rows Found. ATTRIBUTES: UNDERLINE BOLD DIM| Kanbay Incorporated. All Rights Reserved

REVERSE BLINK

INVISIBLE NORMAL

DISPLAY Syntax: DISPLAY message [AT row, column] [ATTRIBUTE (attribute-list)] EXAMPLE: DISPLAY Row Added. AT 22,3 ATTRIBUTE (reverse) ATTRIBUTES: UNDERLINE BOLD DIM| Kanbay Incorporated. All Rights Reserved

REVERSE BLINK

INVISIBLE NORMAL

PROMPTSYNTAX: PROMPT message [ATTRIBUTE (attribute-list)] FOR [CHAR] variable [ATTRIBUTE (attribute-list)] END PROMPT EXAMPLE: PROMPT Are You Sure? Y/N FOR CHAR answer ATTRIBUTES: UNDERLINE BOLD DIM| Kanbay Incorporated. All Rights Reserved

REVERSE INVISIBLE BLINK NORMAL

OPTIONS EXAMPLE: OPTIONS MESSAGE LINE FIRST + 2, ERROR LINE 23, PROMPT LINE LAST -3

| Kanbay Incorporated. All Rights Reserved

Syntax for creation and compiling of a Form To create a default form use form4gl d To compile a form named filename.per use form4gl filename The .per extension is eliminated

| Kanbay Incorporated. All Rights Reserved

FORMMANDATORY sections Database section Screen section Attribute section OPTIONAL Sections Table section Instruction section

| Kanbay Incorporated. All Rights Reserved

Database SectionThe DATABASE section identifies the database (if any) on which the form is based. This can be any database that the engine can access, including remote databases. The DATABASE section is required , even if the form does not reference any database tables/columns. Syntax: DATABASE FORMONLY You can specify only one database. Example : DATABASE xyz DATABASE xyz@server To create a form that is not related to any database , use FORMONLY and omit the TABLES section. Also , the table name has to be formonly in the ATTRIBUTES section for each of the field in the screen.

| Kanbay Incorporated. All Rights Reserved

ATTRIBUTE SECTION It links display fields to database columns by using field tags

| Kanbay Incorporated. All Rights Reserved

FORM ATTRIBUTES:AUTONEXT COLOR COMMENTS UPSHIFT DOWNSHIFT DEFAULT REQUIRED INVISIBLE REVERSE WORDWRAP NOENTRY VERIFY INCLUDE

| Kanbay Incorporated. All Rights Reserved

TABLE SECTIONThe TABLES section lists the database tables that are referenced in the specification file. You must list in this section any table, view or synonym whose column is referenced in the form. The table CANNOT be a temporary table.

| Kanbay Incorporated. All Rights Reserved

Instruction Section Used to define screen records and screen arrays Change the default delimiters for display fields.

| Kanbay Incorporated. All Rights Reserved

OPEN FORM Syntax: OPEN FORM form-name FROM form-file Example: OPEN FORM cust FROM cust_form Cust_form :Name that you gave the form when it was created Cust :How you will refer to the form throughout the program.

OPEN FORM only loads the form onto the memory and does not display it.| Kanbay Incorporated. All Rights Reserved

FORM DISPLAY FORM: DISPLAY FORM cust Opens the form from the memory. CLEAR SCREEN: Clears the form from the screen but the form still exists in the memory. CLOSE FORM: CLOSE FORM cust Removes the form from the memory.

| Kanbay Incorporated. All Rights Reserved