Informix Training

  • Published on
    15-Oct-2014

  • View
    1.858

  • Download
    5

Embed Size (px)

DESCRIPTION

basic Informix Training

Transcript

<p>INFORMIX-4GL TRAINING</p> <p> Kanbay Incorporated - All Rights Reserved</p> <p>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-&gt;Intermediate fles-&gt;Executable file .4ge</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>Differences b/w the two versions: RDS Compile Time Run Time Less More C Compiler More Less</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>Basic Components of Informix 4GL PROGRAM MODULE FUNCTION FORM</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>Program Blocks MAIN FUNCTION REPORT</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>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 &gt;myprog.4gi Executing the program fglgo filename.4go OR fglgo myprog.4gi| Kanbay Incorporated. All Rights Reserved</p> <p>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</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>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</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>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</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>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</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>Initialization of VariablesLET: Assigns value to a variable. Example: LET fname = John Let x = 5 Initialize: INITIALIZE variables to NULLExample: INITIALIZE lname TO NULL</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>Scope of VariablesGlobal Module LocalEXAMPLE:</p> <p>glob.4glGLOBALS DEFINE var1 CHAR(1) END GLOBALS</p> <p>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</p> <p>Variable Scope var1 var2 Var3 var4 Global Module Local Local</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>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</p> <p>Decision and Looping Statements IF CASE WHILE FOR</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>Decisions: IF StatementSYNTAX:IF THEN .. ELSE . END IF</p> <p>Example :IF var_name MATCHES [Yy] THEN ERROR Customer will be deleted. ELSE ERROR Delete cancelled. END IF.</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>IF Within Other Statements Syntax:IF .THEN IF..THEN END IF END IF</p> <p>EXAMPLE:IF state=IL THEN IF zipcode MATCHES 601* THEN ERROR City is Schaumburg END IF END IF</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>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.</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>Logical Loop: WHILE Loop Syntax:WHILE Boolean expression statement(s). [EXIT WHILE] [CONTINUE WHILE].. END WHILE</p> <p>EXAMPLE:WHILE boss_in_office = TRUE CALL act_busy() RETURNING boss_in_office END WHILE</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>FOR LoopSyntax:FOR integer variable = integer expression to integer expression [STEP integer expression] statement [CONTINUE FOR]. [EXIT FOR]. END FOR</p> <p>Example:DEFINE i SMALLINT FOR i=1 TO 10 DISPLAY i = , i AT i,1 END FOR</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>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.</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>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)</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>Screen Interaction Statements ERROR DISPLAY MESSAGE PROMPT</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>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</p> <p>REVERSE BLINK</p> <p>INVISIBLE NORMAL</p> <p>ERROR Syntax: ERROR display-list [ATTRIBUTE(attribute-list)] EXAMPLE: ERROR No Rows Found. ATTRIBUTES: UNDERLINE BOLD DIM| Kanbay Incorporated. All Rights Reserved</p> <p>REVERSE BLINK</p> <p>INVISIBLE NORMAL</p> <p>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</p> <p>REVERSE BLINK</p> <p>INVISIBLE NORMAL</p> <p>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</p> <p>REVERSE INVISIBLE BLINK NORMAL</p> <p>OPTIONS EXAMPLE: OPTIONS MESSAGE LINE FIRST + 2, ERROR LINE 23, PROMPT LINE LAST -3</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>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</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>FORMMANDATORY sections Database section Screen section Attribute section OPTIONAL Sections Table section Instruction section</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>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.</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>ATTRIBUTE SECTION It links display fields to database columns by using field tags</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>FORM ATTRIBUTES:AUTONEXT COLOR COMMENTS UPSHIFT DOWNSHIFT DEFAULT REQUIRED INVISIBLE REVERSE WORDWRAP NOENTRY VERIFY INCLUDE</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>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.</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>Instruction Section Used to define screen records and screen arrays Change the default delimiters for display fields.</p> <p>| Kanbay Incorporated. All Rights Reserved</p> <p>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.</p> <p>OPEN FORM only loads the form onto the memory and does not display it.| Kanbay Incorporated. All Rights Reserved</p> <p>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.</p> <p>| Kanbay Incorporated. All Rights Reserved</p>