Informix(Aj)

download Informix(Aj)

of 69

Transcript of Informix(Aj)

  • 7/21/2019 Informix(Aj)

    1/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    1

    INFORMIX PRODUCT LINE OVERVIEW

    Informix provides leading-edge products for developing and implementing informationmanagement applications for open systems. The core products include application development

    tools, database servers, and connectivity software.

    ? The application tools provide the user interface to build and run applications.

    ? The database server handles all data management, including the storage and retrieval ofdata.

    ? Connectivity software provides the ability to access data in both Informix and non-Informix databases across a broad range of hardware platforms.

    Informix tools can access non-Informix databases through emerging industry standards,

    such as ODBC and DRDA, while allowing third-party tools to access our database servers.

    Industry-standard SQL is used to communicate requests for data from the application tothe database server. All products are based on ANSI-standard Structured Query Language

    (SQL) and run on a variety of operating systems including UNIX, Windows, Windows NT,OS/2, and Machintosh.

    APPLICATION DEVELOPMENT TOOLS

    The application tools allow you to:

    ? Design and build data entry and query screens? Create reports

    ? Build robust applications

    Wide choice of tools including:

    ? INFORMIX-NewEra

    ? INFORMIX-4GL

    ? INFORMIX-SQL

    ? INFORMIX-ESQL

    ? Third-party tools

    Application

    Development

    Tools

    Connectivity

    Database

    Servers

  • 7/21/2019 Informix(Aj)

    2/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    2

    The tools you will use depends on:

    ? The application requirements

    ? The hardware environment (graphical vs. character)? The expertise and preferences of the development staff

    DATABASE SERVERS

    Informix offers a choice of database servers, allowing systems to be tailored to matchavailable resources and technical expertise.

    The database server is responsible for providing:

    ? Optimal data access? Data integrity

    ? Data security

    ? Data availability

    Types of Database Servers:? INFORMIX-SE? INFORMIX-OnLine? INFORMIX-OnLine Dynamic Server

    CONNECTIVITY PRODUCTS

    Informix connectivity products provide SQL-based connectivity to Informix and non-

    Informix databases on a broad range of hardware platforms.

    ODBC-ENABLED APPLICATIONS

    Open Database Connectivity (ODBC) is an interface which permits a single application

    to access multiple database management systems using SQL. With ODBC, you can connect MSAccess, Visual Basic, Lotus Notes, and many other ODBC-enabled applications to an Informix

    server. This technology gives you the freedom to choose your favorite Windows application

    tool, and the power and flexibility of an Informix database server across a full range of scalable

    platforms.

    RELATIONAL DATABASE CONCEPTS

    In relational database systems such as Informix, the data is organized and stored in tablesor entities, which are just a collection of columns and rows. Rows are the horizontal parts of the

    table or are otherwise referred to as instances. Columns are the vertical parts of the table, which

    are also known as attributes. Tables, rows, and columns are a way of organizing the data and

    giving you an understanding of a relational model.

  • 7/21/2019 Informix(Aj)

    3/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    3

    USER REFERENCE

    CONNTECTING WINDOWS 98 CLIENT TO SCO UNIX SERVER:

    Boot the Windows 98 machine and no need to Login into NT Network. Now, follow thestep below:

    Start ? Run ? Type telnet 192.177.166.20 ? OK

    LOGIN INTO INFORMIX:

    To login into informix, the system asks login and password from the user. If both ofthem are correct only, the user is permitted to login into the INFORMIX system.

    Login : user1

    Password: 123

    STARTUP & SHUTDOWN OF INFORMIX SERVER:

    After the successful login, the DBA has to startup the INFORMIX server daily in the

    morning. Then only any INFORMIX commands may work with database. Daily evening the

    INFORMIX server should be shoutdown in the proper method.

    Command Description

    oninit v Initialise INFORMIX server online in verbose mode

    onmode ky To shutdown the INFORMIX server

    STARTING INFORMIX TOOLS:

    To start INFORMIX tools, type the following commands at the UNIX command prompt.

    Command Description

    dbaccess To start dbaccess tool

    isql To start INFORMIX-SQL tool

    r4gl To start INFORMIX-4GL tool

  • 7/21/2019 Informix(Aj)

    4/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    4

    USER LOGOUT FROM INFORMIX:

    To logout from INFORMIX, the user has to type exit (or) ctrl+d in the UNIX

    command prompt. The connection to host is lost.

    SHUT DOWN SCOUNIX SERVER (SUPER USER):

    To shutdown the UNIX server, the super user has to type

    shutdown y g0 i6 shutdown & reboot ( init level 6 )-g0 immediate shutdown

    -y shutdown confirmation

    -g2 Powers down machine after 2 minuties

    FREQUENTLY USED VI EDITOR COMMANDS:

    Command FunctionInput Mode

    i Inserts text to left of cursor

    I Inserts text at beginning of linea Appends text to right of cursor

    A Appends text at end of line

    o Opens line below

    O Opens line aboverch Replaces single character under cursor with ch

    R Replaces text from cursor to rightex Mode

    :w Saves file and remains in editing mode

    :x (or) :wq Saves file and quits editing mode:q Quits editing mode when no changes are made to file

    :sh Escape to the UNIX shellCommand mode

    x Deletes a single character under the cursor

    dd Deletes the current line

    h (or backspace) Moves cursor left one position

    l (or spacebar) Moves cursor right one positionk Moves cursor up one position

    j Moves cursor down one position

  • 7/21/2019 Informix(Aj)

    5/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    5

    DBACCESS

    INTRODUCTION

    DBaccess is a tool designed to enable you to access and manipulate the structure of thedatabase as well as the data within the database. It provides menu-driven access to basic

    database functionality. DBaccess supports a query option to allow you to issue SQL commands

    against the data in the database tables. It also supports altering tables through a menu-driven

    environment. DBaccess supports most actions that can be performed against a database table,

    including create, drop, alter, and fragment. DBaccess can also be used to gather information

    about a table including the current table size, active constraints, current triggers, indexes, and

    existing security privileges.

    The specific functions supported depend on the release of the engine you are operating.

    The options also vary depending on the type of engine running. The INFORMIX-SE engine and

    the OnLine engine have different capabilities and, therefore, different options within the

    DBaccess tool.

    WHEN IS DBACCESS THE RIGHT TOOL SET ?

    DBaccess is the right tool set for many database administrator (DBA) activities, including

    database maintenance and table maintenance. By using the menu options, you can easilyperform these tasks. DBaccess automatically formats complicated SQL statements such as alter

    table. In general, the purpose of the DBaccess tool is to make the syntax of table and database

    maintenance less complicated.

    DBaccess also allows you to create tables and databases rapidly. It provides a screen

    interface so that you can enter the information for a new table. You also can use DBaccess to

    test SQL statements rapidly.

    DBaccess is not the appropriate tool if your goal is to create a report output from a query

    or a data entry screen. It does not have formatting or screen-painting capabilities.

    To start DBACCESS, type dbaccess in the unix command prompt.

    MAIN MENU

  • 7/21/2019 Informix(Aj)

    6/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    6

    Options Description

    Query-language allows you to use SQL query language.

    Connection allows you to connect or disconnect from a database

    environment.

    Database allows you to select, create, info, drop or close a database.

    Table allows you to create, alter or drop a database table.

    Session allows you to retrieve information about the current DB-ACCESS session.

    Exit allows you to exit from DBACCESS.

    QUERY LANGUAGE

    The first option on the DBaccess main menu is Query language. You can find this same

    Query language tool in the ISQL tools. The following options are on this menu:

    Options DescriptionNew allows you to enter a new query by using a rudimentary text

    editor (SQL editor).

    Run submits the query currently visible on the screen to the enginefor execution.

    Modify allows you to modify the query currently visible on the screen byusing the SQL editor.

    Use-editor allows you to specify a text editor to be used in creating andediting SQL statements.

    Output allows you to send the results of the query to an output device, aprinter, a file, or pipe.

    Choose

    allows you to choose a command file as the current SQLstatements.

    Save allows you to save the query currently visible on the screen to anoperating system file.

    Info allows you to select a table and display information about thattable.

    Drop allows you to delete an operating system file storing a querypreviously saved using the Save option.

    Exit returns you to the main DBaccess menu.

  • 7/21/2019 Informix(Aj)

    7/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    7

    CONNECTION

    The connection option of the main DBaccess menu is useful in connecting to alternative

    database engines or servers. This option allows to connect or disconnect from a databaseenvironment. When you choose Connect, a list of valid connections or servers is displayed.

    Simply select the connection you want. You are allowed to enter a user ID and pass- word forverification purposes. After successful validation of user ID and password, you are connected.

    You can then access the databases valid to that connection as if they were on the same machineand database server as when you initially entered DBaccess. This capability allows DBAs to do

    remote database administration.

    DATABASE

    The Database option of DBaccess is primarily used by DBAs. This option allows toselect, create, info, drop or close a database. The following options are on this menu.

    Options DescriptionsSelect allows you to select a database to work with.

    Create allows you to create a new database.

    Info allows you to retrieve information about the database.

    Drop allows you to delete a database.

    Close allows you to close the current database.

    Exit allows you to return to the DBACCESS menu.

    These are the primary uses of this command:

    ? It prevents DBAs from needing to remember the details of the create database command.

    ? It displays rudimentary statistics about a database.

    ? It allows DBAs to view stored procedures.

    Creating a database by using DBaccess has two advantages. You don't need to remember

    the exact syntax of the create database statement., and the system prompts you for the dbspace.

    The ability to view stored procedures is valuable. You can analyze the stored procedure

    without having to remember the exact SQL syntax to retrieve the procedure from the database.

  • 7/21/2019 Informix(Aj)

    8/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    8

    If a copy of the procedure is required, you can use cut and paste or command-line options ofDBaccess to place the stored procedure code in an operating system file.

    TABLE

    Both DBAs and programmers will find constant use for this option. Whether it is to look

    up a table and column name or perform complex database maintenance, this option hascapabilities to perform the needed work. The various options of the Table selection under

    Informix are given below:

    Options DescriptionsCreate allows you to create a new table.

    Alter allows you to alter the structure of the existing table.

    Info allows you to display information about the tables in thecurrent database.

    Drop allows you to drop a table.

    Exit allows you to return to the DBACCESS menu.

    The Info option of DBaccess is read-only, and creating a new table using DBaccess

    usually doesn't affect others on the system. DBaccess makes the job of creating and alteringtables significantly easier than directly typing standard SQL statements, you must use DBaccess

    with the same caution and care required of all system utilities.

    SESSION

    The Session command displays information about the Informix session you're currentlyconnected to. This information helps you keep straight what the settings are in the current

    environment.

    CREATING A TABLE

    In your database, you can proceed to create and populate tables. From the main menu,

    choose "Table" option.

  • 7/21/2019 Informix(Aj)

    9/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    9

    This is the place you do all kinds of operation on tables, such as creating a new table,altering the schema of a table, dropping a table, and checking the information of a table.

    ? To create a table:

    ? Choose "Create" option.

    ? Enter the name of the table after the prompt "CREATE TABLE >> ".

    ? Choose "Add" option to add a new column. Enter the column name, andcolumn type.About Index, you can choose "No" not to add index for the column. After you

    learn the knowledge of index, you can modify it later.About Nulls, choose "Yes" to allow the column has null values, or "No" to

    forbid.Repeat the above for adding remaining columns.

    Press Esc key to go back to parent menu.? Choose "Modify" option to modify the definitions of existing columns.

    ? Choose "Drop" option to remove existing columns.

    ? Choose Exit option and choose Build-new-table to save changes made tothe table.

    ? To alter the structure of existing table

    ? Choose "Alter" option.

    ? Select the name of the table you want to modify.

    ? Choose "Add", "Modify", "Drop", or other options the same as creating a table toalter the structure of the table.

    ? Choose Exit option and choose Build-new-table to save changes made to thetable.

    USING SQL QUERY

    From the main menu, choose "Query-language" option.

    This is the place you execute SQL query. You can construct a new SQL query, make

    modification on the query, and run the query.

    To create a new SQL query:

    ? Choose "New" option? Enter the SQL query

    ? After editing the query, press key.

  • 7/21/2019 Informix(Aj)

    10/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    10

    To run a current SQL query:

    ? Select "Run" option to execute the SQL query.

    To modify the current query:

    ? Select "Modify" option to goto SQL editor.

    ? After editing the query, press key.

    To save the current query:

    ? Select "Save" option.

    ? Give name to the command file and press Enter key.

    ? The message Script saved in .sql displays at the bottom row.

    To choose a command file:

    ? Select "Choose" option.

    ? Select the query command file and press Enter key.

    SQL editor commands:

    Command Operation

    Esc Done editing

    Ctrl X Delete characterCtrl A Typeover / Insert

    Ctrl D Delete rest of line

    Ctrl R Redraw the screen

  • 7/21/2019 Informix(Aj)

    11/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    11

    INFORMIX-SQL

    INTRODUCTION

    INFORMIX-SQL, commonly known as ISQL, is a set of tools provided by InformixSoftware to support developers. ISQL has a long history with Informix. These tools were

    provided with Informix software products before the corporation was named Informix. Prior to

    the advent of INFORMIX-4GL, they were the only fourth-generation tools available through

    Informix.

    WHEN IS ISQL THE RIGHT TOOL SET ?

    ISQL is a set of tools, and each tool has its unique purpose. In general, ISQL is the rightset of tools when you need a quick prototype or a simple application.

    The Report option invokes the ACE report generator. ACE is excellent for generating

    quick reports. It supports SQL select statements, including the creation of temporary tables.

    Some very complex SQL select logic is supported with ACE. It also contains good reportformatting capabilities with built-in control break logic for totals and subtotals. It does have

    some limited logic capabilities, including temporary variables.

    The Form option creates Perform screens. Perform is a screen-generation utility. Theentry screens created by Perform can facilitate data validation, enable intelligent cursor

    movement, and process multiple table relationships. They are excellent for quick data

    maintenance screens for data entry tables such as state abbreviations. They are also effective if

    the application requires no major logic supporting the data entry process.

    The User-menu option creates quick, hierarchically based menu structures. They are

    reasonably flexible and often sufficient for the menuing needs of a system. However, the

    presentation of the menus is not customizable.

    To start INFORMIX SQL, type isql in the unix command prompt.

    INFORMIX-SQL MENU

  • 7/21/2019 Informix(Aj)

    12/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    12

    Options Description

    Form Run, Modify, Create or Drop a form

    Report Run, Modify, Create or Drop a report

    Query-language Use Informix Structured Query Language

    User-menu Run or modify a custom-built menu

    Database Select, Create or Drop a database

    Table Create, Alter or Drop a database table

    Exit Exit Informix-SQL

    DATABASE

    Options DescriptionSelect Select a database to work with

    Create Create a new database

    Drop Drop a database

    Exit Return to the INFORMIX-SQL main menu

    TO SELECT ANY DATABASE:

    Database Select Select any database (say Stores7@bnm) and pressEnter key.

    TO EXIT FROM DATABASE MENU:

    Database Exit

  • 7/21/2019 Informix(Aj)

    13/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    13

    TABLE

    Options Description

    Create Create a new table

    Alter Alter the structure of an existing table

    Info Retrieve information about the tables in the current database

    Drop Drop a table from the database

    Exit Return to the INFORMIX-SQL main menu

    CREATE A NEW TABLE

    To create a new tableTable Create Type table name(saysan1) followed by Enter key

    Options Description

    Add Adds columns to the table above the line with the highlight

    Modify Modify column definitions

    Drop Drop the highlighted column from the table

    Screen Displays the next screen of the tableExit Leaves the CREATE TABLE menu

    i) choose the option Add followed by Enter keyii) Column: Type column name (say PerNo) followed by Enter keyiii) Data type: Select any data type using space bar.

    Press Del key for go back to parent menu.iv) Length: Type length for the field if applicablev) Index: Add index san1: Yes / No:

    Yes : for specifying this column to have an index. Otherwise select No.

  • 7/21/2019 Informix(Aj)

    14/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    14

    If Yes is selected, the following options appears:

    a) Add Duplicates san1: Yes / NoYes : Permits duplicate values in this column

    No : Does not permit duplicate data values in this columnb) Add Fill Factor percentage: Just press Enter key.

    vi) Null:Add Nulls : Yes / No

    Yes: Permits null values in this columnNo: Does not permit null values in this column

    Repeat steps i) to v) for adding remaining columns.

    Press Del key to goto parent menu and select Exit

    Build-new-table: Builds a new table and returns to the table menu

    Discard-new-table: Keeps the old table (discard changes) and returns to the Table menu

    select Build-new-Table followed by Enter key

    AVAILABLE DATA TYPES

    ADD TYPE san1: Char Number Serial Date Money date-Time IntervalVariable-length

    ------------------------------------------------------------------------- Press CTRL-W for Help ----------

    Options DescriptionChar Permits any combination of letters, numbers and symbols

    Number Displays the NUMBER menu

    Serial Permits sequential serial numbers starting with any positive value

    Date Permits dates

    Money Permits dollars and cents

    date-Time Permits datetime values

    Interval Permits interval values

    Variable-length Displays the VARIABLE-LENGTH menu for the variable length columns

  • 7/21/2019 Informix(Aj)

    15/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    15

    DATA TYPE : NUMBER :

    Integer Permits whole numbers in the approximate range 2 billion to 2 billion

    Smallint Permits whole numbers in the range 32,767 to 32,767

    Decimal Permits numbers with a decimal point and upto 32 significant digits

    Displays the PRECISION menu.

    Smallfloat Permits numbers with a decimal point and 8 significant digitsFloat

    Float Permits numbers with a decimal point and 16 significant digits

    DATA TYPE : VARIABLE-LENGTH:

    Varchar Variable-length data containing a maximum of 255 characters

    Text Variable-length data containing a maximum of 2 giga bytes

    Byte user-defined type containing a maximum of 2 giga bytes

    ALTER ANY EXISTING TABLE

    To alter the structure of any existing table

    Table Alter Select the table(saysan1) followed by Enter key

    The options available in the alter table menu and its functions are same as create table

    menu options.

    INFORMATION ABOUT TABLE

    To retrieve information about the tables in the current databaseTable Info Select the table(saysan1) followed by Enter key

  • 7/21/2019 Informix(Aj)

    16/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    16

    Options Description

    Columns Display column names and data types for a table

    Indexes Display information about indexes for the columns in a table

    Privileges Display user access privileges for a table

    Status Display status information for a table

    Table Select a table from the current database

    Exit Return to the SQL menu

    COLUMNS:

    INDEXES:

    PRIVILEGES:

  • 7/21/2019 Informix(Aj)

    17/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    17

    STATUS:

    DROP TABLE

    To drop a table from the database

    Table Drop Select the table (saysan1) followed by Enter key

    No: No, I do not want to drop it

    Yes: Yes, I do want to drop it.

    Select Yesto drop the table.

    FORM

    Options DescriptionRun Use a form to enter data or query a database

    Modify Modify a form specification

    Generate Generate a default form

    New Create a new form specification

    Compile Compile a form

    Drop Drop a form from the database

    Exit Return to the INFORMIX-SQL main menu

  • 7/21/2019 Informix(Aj)

    18/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    18

    GENERATE A DEFAULT FORM:

    Form Generate Enter the name to assign to the form (saysanfrm)followed by Enter key

    Choose Table >> Choose the table to be used(say san1) followed by Enter key

    Options Description

    Table-selection-complete Continue creating a default form with the selected tables

    Select-more-tables Select another table to include in the default form

    Exit Returns to the FORM menu

    Select Table-selection-complete followed by Enter key.

    The message The screen form specification was successfully compiled displays.

    RUN AN EXISTING FORM

    Form Run Select the form (saysanfrm) followed by Enter key

    Options Description

    Query Searches the active database table

    Next Shows the next row in the current list

    Previous Shows the previous row in the current list

    View Runs editor commands to display BLOB contents

    Add Adds a row to the active database table

    Update Changes a row in the active database table

    Remove Deletes a row from the active database table

    Table Selects the current table

    Screen Shows the next page of the form

    Current Displays the current row of the current table

  • 7/21/2019 Informix(Aj)

    19/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    19

    Master Selects the master table of the current table

    Detail Selects a detail table for the current table

    Output Outputs selected rows in form or report format

    Exit Returns to the INFORMIX-SQL menu

    ADD NEW RECORD

    To add a new record in the current table, select Add and start entering data.

    Use Arrow keys to move cursor and Escape key to add new record.The message Row added appears at the bottom row after adding each record.

    QUERY IN THE CURRENT FORM

    To make any queries in the current form, select Query and start typing any criteria in

    the relevant column(s) and press Esc key to execute the query. The criteria may be any value

    or any relational expression. The criteria is case sensitive.

    If you type CM-II in the design column and press Esc key, you may get all the

    employee rows having designation CM-II having displayed one record at a time. If more thanone row is found, select Next/ Previous options to see the Next / Previous rows which satisfies

    the given criteria.

  • 7/21/2019 Informix(Aj)

    20/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    20

    UPDATING CURRENT ROW

    To update any values of current row, select Update option and change any value in the

    respective columns. You press Esc key to save the changes (or) Del key to abandon changes.

    REMOVING CURRENT ROW

    To remove the current row, select Remove option. It deletes the current row from theactive database table.

    OUTPUT SELECTED ROWS

    To output selected rows in form or report format, select Output option.

    Enter output file name say sample.outand press enter key.

  • 7/21/2019 Informix(Aj)

    21/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    21

    Options Description

    Append Adds new data to an existing output file

    Create Creates a new output file

    Select Create and current-list options.

    Options Description

    Current-list Writes the current list to the file

    One-page Writes the displayed screen to the file

    Options Description

    Unload-format Writes the selected output in ascii format

    Screen-format Writes the selected output in screen format

    Select Unload-format option and Exit to exit from the Run menu.

    In the UNIX command prompt, type vi sample.out (or) cat sample.out to see the

    contents of output file sample.out.

  • 7/21/2019 Informix(Aj)

    22/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    22

    REPORT

    The Report menu takes you into a submenu that allows you to generate, edit, compile,and run ACE reports. The ACE report writer quickly formats simple reports. You can enter a

    sequence of SQL statements that generate a final sorted output. This single output thread is usedas the input to the report formatting section of the report. Complex selection logic can be

    supported if it can be accommodated using multiple select statements and temporary tables togenerate a final single output stream.

    ACE does not support table updating. If the application requires the ability to update

    tables, ACE is not the appropriate tool. ACE can do the selection and create an output file thatcan be used as input to an update procedure, but updating within an ACE report is not supported.

    ACE does not support extensive logic. Although ACE does support if -then - else

    constructs, its ability to do extensive logic handling is limited. ACE has a built-in limit of SQLvariables. It also has a tendency to fail on deeply nested if statements.

    ACE has a built-in totaling mechanism for control breaks. These control breaks must be

    specified in the order by clause of the final SQL statement. Complex totaling can becumbersome in ACE. If totaling must be done on fields outside the control breaks, you must use

    defined variables. The built-in limit can restrict the flexibility and quantity of such totals.

    Options DescriptionRun Runs a report

    Modify Modify a report specification

    Generate Generate a default report

    New Create a new report specification

    Compile Compile a report

    Drop Drop a report from the database

    Exit Return to the INFORMIX-SQL Main menu

    GENERATE A DEFAULT REPORT:

    Report Generate Enter the name to assign to the report (saysanrep)

    followed by Enter key

  • 7/21/2019 Informix(Aj)

    23/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    23

    Choose Table >> Choose the table to be used(say san1) followed by Enter key

    The report specification was successfully compiled message appears at the bottom row.

    RUN AN EXISTING REPORT:

    Run Choose a report(saysanrep) then press Return key

    This report continues to print on the screen until it is complete. If you have more data

    than will appear onscreen, the generated report allows the data to scroll off the screen.

  • 7/21/2019 Informix(Aj)

    24/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    24

    MODIFY AN EXISTING REPORT:

    Modify Choose a report(saysanrep) then press Return key. Press Return key

    in the USE-EDITOR option to select the default vi editor.

    Using vicommands, you can edit the report coding.

    After modification is over, press Esc x(:x) to save and exit from vi editor.

    Options Description

    Compile Compile the report specification

    Save-and-exit Save the report & return to REPORT menu

    Discard-and-exit Discard changes and return to REPORT menu

    Select Compile followed by Save-and-exit option.

    DROP AN EXISTING REPORT:

    Drop Choose a report (saysanrep) then press Return key.

    Options DescriptionNo No, I do not want to drop it

    Yes Yes, I do want to drop it

    Select Yes to drop the selected report, otherwise No to cancel the drop operation.

  • 7/21/2019 Informix(Aj)

    25/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    25

    USER-MENU

    By using the User-menu, you can quickly create a hierarchically based menu system. Toutilize the tool, your menuing design must be entirely based on a master menu/detail menu

    relationship. Each entry on the main menu can be one of the following types:

    ? F: Run a form

    ? M: Call another menu

    ? P: Execute another program or operating system command

    ? Q. Execute an ISQL query or other command file

    ? R: Run a report

    ? S: Execute a script menu

    The menus are stored in the database. You should have the menu structure designedbefore entering the menu items. To begin entering the information, select the lowest level menu

    and give it a name. This menu does not call any other subordinate menus.

    Press M for Master, and then press A for Add. Type the name of the menu and the title

    you want the user to see on the screen. The title can be long and descriptive; the name is limited

    in length. The name is used only within by the menuing system to track relationships between

    menus. Next, press the Esc key.

    You have added your first menu. Next, add the individual items for the menu. It is best

    if they already exist or if you at least know the exact names the called programs, reports,

    procedures, and so on will have. You can always modify the menus, but planning ahead is best.To begin entering the menu selections, press D for Detail. The cursor then moves to the bottomhalf of the screen on Selection Number. Press A for Add. Then type the selection number and

    selection type. Next, enter the selection text as you want it to appear to the user. The final entryis the exact command string as it should be executed from the operating system.

    Continue to enter your menu one item at a time. To test the current Structure at any time,

    exit from the entry modification screen and choose Run. Your menu is then displayed on screen.You can test your work immediately.

    The User-menu option is a great tool for creating menus quickly. Its flexibility in calling

    any type of operating system program enhances its ability to support any type of applicationdeveloped in the UNIX environment.

  • 7/21/2019 Informix(Aj)

    26/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    26

    STRUCTURED QUERY LANGUAGE (SQL)

    SQL statements are used to perform all direct functions on the database. The statementsand keywords used will lead to the database operations being performed. SQL commands

    consist of command verbs, optional clauses, keywords. and parameter operands. The use ofthese in SQL syntax permits exact specification of the data requests. The language allows single

    and double byte characters to be used in identifiers and variables. SQL has many types of

    commands; some are for handling the data, and some are for controlling administrative matters.

    FEATURES:

    A significant feature of SQL is that it can be used by two different interfaces. SQL is

    both an interactive query language and a database Programming language. This means that anySQL statement that can be entered at a terminal can also be embedded in a program.

    Finally, SQL processing is also known as a set level language, which means your

    updates will change records and return the results. You simply state what you want without

    specifying a procedure, and the system automatically completes the process.

    SQL is the communicating device to the relational database management system. You

    will find SQL to be a simplified and straightforward process for accessing data. When you are

    familiar with the language, fairly sophisticated data processing can be done. The following listlogically summarizes the SQL language:

    ? Simple flexible database access language

    ? Standard relational language

    ? English-like query language

    ? Supports many relational products, such as DB2, Oracle, Informix, Sybase.

    CREATING A TABLE

    To create a simplest table, it is very easy:

    Syntax: CREATE TABLE (< list of column definitions including column name and data type >

    );

    Example: CREATE TABLE test (i integer,

    s varchar(10));

    For each column, you can also add any of the following property or column-level

    constraint:

  • 7/21/2019 Informix(Aj)

    27/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    27

    ? DEFAULT to set the default value.

    ? NOT NULL -- the column value can not be null;

    ? UNIQUE -- the column value can not be duplicated

    ? PRIMARY KEY -- the column acts as key

    ? REFERENCES () -- the columns refer toa column in another table. The referenced key must have UNIQUE or PRIMARY

    KEY constraints.

    If you have all the above definitions, the order to write it is DEFAULT clause the first,

    then NOT NULL, and other constraints at last.

    Example: CREATE TABLE accounts (

    acc_num integer PRIMARY KEY,acc_code integer UNIQUE,open_date date DEFAULT TODAY

    );

    You can also specify any of the following table-level constraints:

    ? UNIQUE()

    ? DISTINCT ()

    ? PRIMARY KEY()

    ? FOREIGN KEY() REFERENCES ()? CHECK() -- check the constraints be met before data be assigned

    Example: CREATE TABLE customer (

    ssn char(9),name varchar(20) NOT NULL,

    acct integer,age integer,

    PRIMARY KEY(ssn),FOREIGN KEY(acct) REFERENCES accounts(acc_num),

    CHECK( age>=18 )

    );

    You can also use CHECK () to check constraints to designate conditions

    that must be met before data can be assigned to a column during an INSERT or UPDATEstatement.

    Example: CREATE TABLE people (id serial PRIMARY KEY,

    name varchar(20),

    age int CHECK (age>0),

  • 7/21/2019 Informix(Aj)

    28/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    28

    sex char CHECK (sex='M' OR sex='F'),birthday date,

    working boolean,salary money,

    descript text,CHECK ( (working AND (salary IS NOT NULL)) OR

    (NOT working AND salary IS NULL) ));

    GETTING RID OF A TABLE

    To remove a table from your database, execute

    Syntax: DROP TABLE ;

    Example: DROP TABLE test;

    CREATING A VIEW

    You can use CREATE VIEW statement to create a new view based on existing tables andviews in the database.

    Syntax: CREATE VIEW (

    ) AS FROM ;

    Example: CREATE VIEW student( id, name )

    AS SELECT * FROM test;

    CREATING AN INDEX

    An important technique for improving the performance of queries is to create indexes. Anindex on an attribute of a relation allows the database to quickly find the data in the relation with

    a given value for the indexed attribute.

    Syntax: CREATE INDEX ON

    ();

    Example: CREATE INDEX sid_index ON student(id);

    It may be useful if the queries involved in the student id such as the following query:SELECT *

    FROM student

    WHERE id = 10;

  • 7/21/2019 Informix(Aj)

    29/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    29

    SQL - DATA MANIPULATION STATEMENTS

    SQL is the data access language used to communicate with the database manager. Youuse SQL's data manipulation statements to view and store rows in a table, as well as modify and

    delete these rows. Here are the statements you use:

    ? SELECT

    ? INSERT

    ? UPDATE

    ? DELETE

    SELECT statement is the definitive command found in SQL. Not only does it allow you

    to see anything within the database, but it also helps the next three commands to be more precise.You use the INSERTstatement to store rows in a table. The statement can add a row to an empty

    table or a table that already has populated data. You use the UPDATEstatement if you want tochange any of the existing rows in a table. You use the DELETEStatement to delete one or morerows in a table. This chapter reviews the execution of each statement.

    Informix uses an enhanced version of the industry standard query language product.

    Putting SQL statements into a program allows you to query a database as well as make

    modifications to existing rows.

    QUERYING DATA (SELECT STATEMENT)

    Using the SELECTstatement is the primary way toquery your database. Itis the mostimportant SQL statement and can be the most complex. The SELECT statement does not

    modify data in the database; you use it only to query the data. You can select from a database

    table, a view, or the system catalog tables.

    You can usethe SELECTstatement in the following ways:

    ? Retrieve data from a database

    ? Create new rows with the INSERTstatement.

    ? Update data with the UPDATEstatement.

    There are five SELECT statement clauses, even though only two clauses--SELECT and

    FROM--are required. You must use the clauses in the following order:

    ? SELECT

    ? FROM

    ? WHERE

    ? ORDER BY

    ? INTO TEMP

  • 7/21/2019 Informix(Aj)

    30/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    30

    You can run a query on a single table of a database to retrieve all or specific columns orrows and order the data in different ways. If you specify an asterisk (*) in your select statement,

    all the columns are returned in their defined order. You can specify which columns you want byincluding the list of column names immediately after the SELECT keyword in the statement.

    The order in which the columns are selected is the order in which they are returned by default.

    eg. SELECT * FROM tablelSELECT column1, column2, column3 FROM tablel

    You can eliminate duplicate rows from being returned by using the DISTINCT or

    UNIQUE keyword in your SELECTstatement.

    WHERE Clause of the SELECT statement

    It is useful for two specific purposes:

    ? Specify the criteria for searching specific rows.

    ? Create join conditions with multiple tables.

    You can use many keywords and operators todefine your search criteria:

    Keywo rds Resul ts in

    BETWEEN Range of values

    IN Subset of values

    LIKEVariable text search

    MATCHES Variable text search

    IS NULL Search for NULL strings

    IS NOT NULL Search for non-NULL Strings

    AND / OR / NOT Logical operators used to connect two or more conditions

    Relat ional Operators Descr ipt ion

    = Equals

    != or Does not equal

    > Greater than

    >= Greater than or equal to

    < Less than

  • 7/21/2019 Informix(Aj)

    31/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    31

    In addition to using the LIKE and MATCHES keywords, you can use a wildcard forvariable text search strings.

    Use with

    MATCHES

    Descr ipt ion

    * Evaluates to 0 or,more characters

    ? Evaluates to a single character

    [ ] Specifies valid values for a single character or a range of values

    \ Specifies a literal for the next character

    ORDER BY Clause of the SELECT statement

    You can instruct the system to sort the selected data in a specific order by using the

    ORDER BY clause on the SELECT statement. By default, data that is retrieved is sorted inascending order. You can add the DESC keyword to your SELECTstatement to sort the data in

    descending order. The ORDER BY column must be in the select list. Columns that arefrequently used with the ORDER BY clause should be indexed for best performance of the

    query.

    FUNCTIONS AVAILABLE IN THE SELECT STATEMENT

    You can use additional functions with the SELECT statement. You use aggregatefunctions to summarize groups of selected rows in a table.

    Funct ion Descr ipt ion

    COUNT Counts the number of rows that are a result ofthe SELECTstatement

    SUM Sums the value of a given numeric column

    AVG Arithmetic means of a given numeric column

    MAX Maximum value of a given column

    MIN Minimum value of a given column

    The next set of functions is the time functions:

    Funct ion Descr ipt ion

    DAY Integer that represents the day

    MONTH Integer that represents the monthWEEKDAY Integer that represents the day of the week (values

    0 through 6 (Sun-Sat))

    YEAR Four digit integer that represents the year

    MDY Returns the date in mm/dd/yyyy format

    DATE Returns a date value

    CURRENT Returns a date/time value that represents the currentdate and time

  • 7/21/2019 Informix(Aj)

    32/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    32

    In addition tothe aggregate and time functions, you can also use the following functions:

    Funct ion Descr ipt ion

    LENGTH Returns the length of a character column

    USER Returns the login account name of the current user

    TODAY Returns the system data

    SITENAME Returns the server name for the INFORMIX-OnLinesystem (defined in the onconfig file where the currentdatabase resides)

    HEX Returns the hexadecimal encoding of an expression

    ROUND Returns the rounded value of an expression

    TRUNC Returns the truncated value of an expression

    GROUP BY and HAVING Clause of the SELECT statement

    Two additional clauses for more advanced queries are GROUP BYand HAVING. The

    GROUPBY clause produces a single row for each group of rows that have the same value in agiven column. The data is sorted into groups and then compressed into a single row for end

    results.

    A GROUP BY clause does not order the result data. If you include an ORDER BYstatement in the select after the GROUP BY clause, the rows are sorted in the specified order.

    The HAVING clause provides a filter for the grouped-by results. This works in

    conjunction with the GROUP BY clause to apply conditions on the groups after they are formed.You do not need to use a HAVING clause with a GROUP BYclause, but in most cases they

    appear in the query together.

    MULTIPLE TABLE SELECT STATEMENTS

    You can select data from two or more tables by using the SELECT statement with the

    FROM and WHERE clauses. The SELECT clause lists the columns from each table that you

    want, the FROM clause lists the tables you are selecting from, and the WHERE clause lists thematching columns in order to join the tables.

    A simple join gets the information from two or more tables with a basis of one column

    for each table. A composite join is a join between two or more tables with two or more columns

    in each table used for the relationship. The following is an example of a simple join to get

    customer information from two tables:

    SELECT * FROM customer_table, address_tableWHERE customer_table.cust_num = address_table.cust_num;

  • 7/21/2019 Informix(Aj)

    33/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    33

    INSERTING DATA

    The SQL INSERTstatement allows a user to enter a row or rows of values into a table.The INSERT statement has two functions: The first is creating one single new row by supplying

    the column values and the second is creating a group of new rows with values derived fromanother table.

    SINGLE ROW INSERTS

    Adding a single row is the simplest form of the INSERT statement. The statement

    creates one new row in a table from a list of defined column values. You use a VALUESclause

    in the statement, and the values to be inserted must have a one-to-one equivalence with the

    columns of the table.

    The following code shows an example of the syntax:

    INSERT INTO tablelVALUES (123, ABC")

    If you do not want to specify every column of the table where you insert a row, you can

    list the column names after the table name and then supply the values for the columns you list.

    The VALUES clause accepts only constant values. You canuse the following values:

    ? Literal numbers, date and time values, and interval values

    ? Strings of characters (quoted)

    ? NULL for null values

    ? TODAYfor today's date

    ? CURRENTfor the current date and time

    ? USERfor the user's name

    When inserting a value into a column, you might find that restrictions were placed on thecolumn. For example, some columns might not allow null values or duplicate values. Also, a

    column restriction can specify the exact values that are allowed tobe inserted.One column in a table can be defined as a SERIAL data type. The database server

    generates values for a serial column. When you specify 0 as the value, the database servergenerates the next value in the sequence. Serial columns do not allow you to insert NULL

    values.

    When performing inserts, the database server makes conversions if necessary. For

    example. when you insert a number or date into a character column, the server converts the

    values to character strings. The database server can also convert between numeric and character

    data types.

  • 7/21/2019 Informix(Aj)

    34/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    34

    MULTIPLE ROW INSERTS

    For the more enhanced INSERT statements, you can replace the VALUES clause with aSELECT statement. This option allows you to insert multiple rows of data with only one

    statement.

    Using the SELECT clause in the INSERT Statement has the following restrictions..

    ? You cannot use the INTO clause.

    ? You cannot use the INTO TEMP clause.

    ? You cannot use the ORDER BY clause.

    ? You cannot use the same table in the INTO clause of the INSERT statement and theFROM clause of the SELECT statement.

    When inserting multiple rows, you have a risk of including invalid data . so the databaseserver terminates the statement if it reaches an invalid value.

    INSERT STATEMENT WITHIN A PROGRAM

    You can embed an INSERT statement in a program justas if you were performing any

    simple SQL statement. An additional feature allows you to use host variables in expressions for

    both the VALUES and WHERE clauses.

    UPDATING DATA

    You use the SQLUPDATE statement to change the values of one or more rows of atable. The two forms of the UPDATE statement are uniform value updates and select value

    updates.

    To update data in a table, you must be the owner of the table or have the UPDATEprivilege for that table. If you update rows in a database without transactions and the update

    fails, your database can be in a state with a half-processed update, and it is not rolled back. If

    your database has transactions, you do the update with the ROLLBACK WORK statement,which automatically rolls back any modifications if the statement fails or does not completely

    finish processing.

    The UPDATE statement can end in a WHERE clause, which determines what rows are

    affected. If you do not include a WHERE clause, then all rows of the table are modified. The

    WHERE clause consists of standard search criteria.

    UNIFORM VALUE UPDATES

    Updating with uniform values happens when you use the SET keyword to add a value fora column. The value is uniformly added to every row unless you state a WHERE clause to be

    more specific on your UPDATE statement:

  • 7/21/2019 Informix(Aj)

    35/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    35

    UPDATE tablelSET fieldl = ABC

    The SET clause identifies each column to be changed and specifies the value that is used

    in making the change. You can have any amount of single-column-to-single-expressionfunctions in an UPDATE statement.

    You can use the NULLkeyword as a column value with the UPDATE Statement.

    SELECTED VALUE UPDATES

    Updating with selected values happens when you take a list of columns and set them to alist of values. This method is basically the same as the first form of updates, but it assigns bulk

    values to existing columns:

    UPDATE tablelSET (fieldl, field2, field3) = ('ABC, DEF, GHI)

    DELETING DATA

    The SQL DELETE statement removes one or more rows from a table. If you usetransaction processing, you cannot recover the deleted rows after the statement is committed.

    Also, when you delete a row, the row is locked for the duration of the transaction. If a large

    number of rows are deleted, keep in mind that all rows are locked. You can lock the entire tableprior to deleting if you know you are processing a lot of rows.

    The advantage of using transaction processing is that, regardless of what happens duringyour process, the database is left in the original state if the statement cannot be completelyprocessed correctly.

    If the WHERE clause is not on the statement, all rows are automatically deleted from the

    table. If you are using INFORMIX-SQL or Informix DBaccess when you use the DELETEstatement without a WHEREclause, you are asked to confirm that Do you want todelete all

    rows in the existing table? Please note that if you use the DELETEclause in a program, you arenot asked for confirmation, and the DELETEprocesses automatically.

    eg. DELETE FROM tablel

    The general Syntax for a DELETE statement is simple, but you must be careful that youaccurately delete the rows that you want. The DELETE keyword identifies the operation you are

    to perform. The FROM clause is next followed by the table name. The WHERE clause

    identifies the rows to be deleted. The search conditions are the same as those in the SELECT

    and UPDATE statements; they can be used to identify many rows, and therefore an accurate

    deletion process takes place.

    eg. DELETE FROM tablel

    WHERE balance = 0;

  • 7/21/2019 Informix(Aj)

    36/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    36

    INFORMIX-4GL

    INFORMIX 4-GL AND CLIENT/SERVER ARCHITECTURE

    Informix-4GL allows you to both provide a far friendlier mode of interaction, and protectvaluable data from end user errors.

    Server

    Client

    Because of its role in the client/server architecture, the 4GL code you write is actually a

    4GL/SQL hybrid. It contains:

    ? 4GL logic for screen handling and the user interface? SQL statements which are sent to the Informix Server to be processed

    TYPES OF INFORMIX-4GL

    There are actually two kinds of INFORMIX-4GL.

    ? INFORMIX-4GL Rapid Development System (RDS) and? INFORMIX-4GL C Compiler Version.

    RAPID DEVELOPMENT SYSTEM

    RDS compiles the source program into pseudo-code (p-code). The time line for

    compiling into p-code is very small. The p-code is later executed through a p-code runner. The

    runner takes the statements that you have written in INFORMIX-4GL and translates them at run-

    time into something the computer can understand. Thus it takes longer time to execute. How

    much longer depends on the type of hardware you are using and what the actual INFORMIX-

    4GL code is doing.

    Informix 4GL-GX

    An important advantage to RDS is ready to access to a graphical presentation of your

    RDS application by means of INFORMIX-4GL/GX. Some of the features are as follows:

    ? 3-D shading enhances the appearance of your 4GL forms

    ? Text fields and their delimiters are replaced by visually distinct form fields offset bycolor or highlighting

    ? Help text is displayed in a separate window, allowing the user to simultaneously viewand use Help and the RDS application.

    InformixServer

    4 GL

    SQL

  • 7/21/2019 Informix(Aj)

    37/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    37

    Informix-4GL Interactive Debugger

    The debugger can be used to trace run-time bugs in your source code. The interactivedebugger allows you as much control over your program as you need:

    ? You can actually watch the code you have written as it executes, stopping it at anytime along the way

    ? You can trace variables so that the execution will stop whenever the value of avariable changes

    ? You can step through the execution line by line, look at the value of a programvariable at any time, and use a host of other commands

    C COMPILER VERSION

    The INFORMIX-4GL code is first translated into ESQL/C Code, then C Code, then

    object, and then into an executable program. So that the compile time is longer. The execution

    time of the finished program is faster than the p-code generated by INFORMIX-4GL RDS. This

    is because the compilation sequence takes the code you have written and translates it directly

    into machine executable code.

    INFORMIX-4GL MAIN MENU

    Options Description

    Module Create, modify, or run individual 4GL program modules

    Form Create or modify 4GL screen forms

    Programs Create, compile or run 4GL application programs

    Query-language Use Informix Structured Query Language

    Exit Exit INFORMIX-4GL

  • 7/21/2019 Informix(Aj)

    38/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    38

    Options Description

    Modify Change an existing 4GL Program module

    New Create a new 4GL Program module

    Compile Compile an existing 4GL Program module

    Program-compile

    Compile an existing 4GL application program

    Run Execute an existing 4GL program module or applicationprogram

    Options Description

    Modify Change an existing form specification

    Generate Generate & compile a default form specification

    New Create a new form specification

    Compile Compile an existing form specification

    Exit Returns to the INFORMIX-4GL menu

    Options Description

    Modify Change the compilation definition of a 4GL applicationprogram

    New Add the compilation definition of a 4GL application program

    Compile Compile a 4GL application program

    Planned_Compile Show the planned compile actions of a 4GL applicationprogram

    Run Execute a 4GL application program

    Drop Drop the compilation definition of a 4GL application program

    Exit Returns to the INFORMIX-4GL menu

  • 7/21/2019 Informix(Aj)

    39/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    39

    Options Description

    New Enter new SQL statements using the SQL editor

    Run Run the current SQL statements

    Modify Modify the current SQL statements using the SQL editor

    Use-editor Modify the current SQL statements using a user-specified editor

    Output Run & send query results to a printer, file or a pipe

    Choose Choose a command file as the current SQL statements

    Save Save the current SQL statements in a command file

    Info Retrieve information about tables in the current database

    Drop Drop an SQL command file

    Exit Returns to the INFORMIX-SQL main menu

    BASIC COMPONENTS OF INFORMIX-4GL

    ? PROGRAM

    ? MODULE

    ? FUNCTION

    ? FORM

    PROGRAM

    A logical sequence of operations to be performed by a computer in solving a problem or

    in processing data.

    MODULE

    A module is a computer file with a specific purpose or function consists of INFORMIX-4GL instructions. It is one piece of the entire program. Program contains at least one module.A module contains a collection of one or more functions.

    FUNCTION

    A routine that performs a specific duty or job which may be required in a program. The

    functionis the basic unit of INFORMIX-4GL code. It is used to set off a series of INFORMIX-4GL statements which should be executed when called upon.

  • 7/21/2019 Informix(Aj)

    40/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    40

    TYPES OF FUNCTIONS:GLOBALS

    The GLOBALS function tells INFORMIX-4GL that the only statement it should find in

    this function is a variable declaration statement. Every program is only allowed one GLOBALSfunction.

    MAIN

    The MAIN function gives INFORMIX-4GL a place to start. INFORMIX-4GL will

    always read the module with the MAIN function in it first. Every program requires exactly oneMAIN function (otherwise INFORMIX-4GL would not know where to start).

    FUNCTION

    A FUNCTION is the basic unit for INFORMIX-4GL code. Programmer has to define

    what each functions purpose is going to be.

    REPORT

    The REPORT function tells INFORMIX-4GL that additional report formatting

    statements may be encountered. Other functions, MAIN, GLOBALS and FUNCTION, will not

    understand these report statement.

    FORM

    Theformis a separate file that is used to specify what the appearance of the visual screendisplay will look like during data entry and manipulation. Forms are a separate entity from the

    rest of your program. Forms are compiled separately and are used by your program. Forms canbe used to display information from a database as well as to update, delete and insert

    information.

    Program

    Modules

    Cust_main.4gl

    GLOBALS

    4GL CODE

    END GLOBALS

    MAIN4GL CODE

    END MAIN

    Cust_add.4gl

    FUNCTION add_cust()

    4GL code

    END FUNCTION

    REPORT cust_list()4GL code

    END REPORT

    Cust_edit.4gl

    FUNCTION delete_cust()

    4GL code4GL code

    FUNCTION update_cust()

    4GL code

    END FUNCTION

  • 7/21/2019 Informix(Aj)

    41/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    41

    SCOPE OF ELEMENTS

    The scope of an element deals with where that particular element is known, or can beused, in an INFORMIX-4GL program. There are three basic types of SCOPE. These can be

    broken down like this:

    Global - Element is known throughout all modules and functions.Module - Element is known to all functions within the module in which the element

    was defined or declared.Local - Element is known only to the function in which it was defined or declared.

    DATA TYPES IN INFORMIX-4GL

    There are eight categories of data types available in INFORMIX-4GL. These categories are

    explained below.

    CHAR Stores any combination of letters, numbers and symbols

    NUMERIC There are several numeric data types designed to store differentkinds of numeric data

    SERIAL Stores sequential integers assigned by 4GL. Usually a primarykey column.

    DATE Stores calendar dates.

    MONEY Stores currency amounts.

    DATETIME Stores point in time.

    INTERVAL Stores values representing a span of time.

    VARIABLE-LENGTH There are several variable-length data types unique to theINFORMIX-OnLine engine.

    Category Data typ es

    CHAR CHAR This is fixed-length data type

    NUMERIC INTEGER Stores whole numbers only Four bytes

    SMALLINT Stores whole numbers only Two bytes

    FLOAT Stores binary floating point numbers Doubleprecision, 14 significant digits

    SMALLFLOAT Stores binary floating point numbers Single

    precision, 7 significant digitsDECIMAL Stores numbers with number of digits specified by the

    user

    MONEY MONEY Stores currency amounts

    SERIAL SERIAL Contains unique numbers that are assigned by thesystem to each row of the table, and stored as

    INTEGERS

    DATE DATE Stores calendar dates

    DATETIME DATETIME It is used when you want to store values that representa specific point in time

  • 7/21/2019 Informix(Aj)

    42/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    42

    INTERVAL INTERVAL It is used to store values that represent a span of time

    VARCHAR This can store between 0 and 255 bytes of character

    data.VARIABLE-

    LENGTH

    BLOB Binary Large Objects are streams of bytes of arbitrary

    value and length. A BLOB can be any arbitrary

    collection of bytes for any purpose.

    DEFINING PROGRAM VARIABLES

    The placement of the DEFINE statement is what gives a variable its scope. Placing aDEFINE in the globals function will make that variable known to all the other functions. It gives

    the variable global scope.

    A DEFINE function can be placed after the globals reference, but before the MAIN. Thisplacement of the DEFINE gives the variable module scope.

    If the DEFINE is placed after a FUNCTION keyword, it will have a local scope. It can

    be referenced in the function where it was defined.

    GLOBAL Element is known throughout all modules and functions

    MODULE Element is known to all functions within the module in which the elementwas defined or declared

    LOCAL Element is known only to the function in which it was defined or declared

    DEFINING EXPLICIT VARIABLES

    The DEFINE keyword is followed by the name of a variable and the data type you wouldlike to assign. You may use any valid data type except SERIAL. The variable is explicitbecause the name and data type are included in the definition.

    Syntax: DEFINE variable-list data-type

    Example: DEFINE fname CHAR(15),

    Start_date DATE,x, y, z INTEGER

    Variable Name

    ? May be a maximum of 18 characters in length

    ? First eight characters must be unique (this may be system dependent)

    ? Must begin with a letter, then can contain letters, numbers and underscores (_)

    ? May be upper or lowercase

  • 7/21/2019 Informix(Aj)

    43/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    43

    DEFINING IMPLICIT VARIABLES

    The DEFINE keyword can be followed by the name of a variable. The data type isassigned by using the keyword LIKE followed by a table.column-name. This is an implicit

    definition because the data type is not plainly expressed, but rather, it is assumed to be the sameas the data type of the column being referenced.

    Syntax: DEFINE variable-name LIKE table.column-name

    Example: DATABASE stores

    DEFINEfname LIKE customer.fname,

    start_date LIKE orders.order_date,

    x,y,z LIKE orders.order_num

    INITIALIZING VARIABLES

    There are two statements that can be used to initialize your variables, LET and

    INITIALIZE.

    The LET Statement

    It is a standard programming statement. It means to take what is on the right side of the

    equal sign and assign it to the variable on the left side. In most cases, you will want to assign a

    NULL as the initial value for a variable.

    The INITIALIZE Statement

    The INITIALIZE statement is used specifically for initializing variables and records toNULL.

    Example:

    LET X = 5LET fname = John

    LET lname = SmithINITIALIZE lname TO NULL

    INITIALIZE nr_customer.* TO NULL

  • 7/21/2019 Informix(Aj)

    44/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    44

    SCREEN INTERACTION STATEMENTS

    THE SCREEN:

    The screen is that area of the terminal where information can be displayed. By default,

    the area of the screen in INFORMIX-4GL is 24 rows by 80 columns. INFORMIX-4GL allowsyou to break the screen area into smaller sections called windows.

    THE WINDOW:

    When you create a window in INFORMIX-4GL, you are actually creating a mini-screen.

    You are reducing the area in which statements can be placed.

    ? You can have as many windows as you want (memory is the only limitation)

    ? Only one window is active at a time

    ? You can change the active window

    ? You can decide what size to make a window

    ? The size of a window can affect other INFORMIX-4GL statements

    THE MESSAGE STATEMENT:

    Syntax:

    MESSAGE display_list [ ATTRIBUTE (attribute list) ]

    Example:MESSAGE Press the first letter of an option. ATTRIBUTE (REVERSE)

    Use the MESSAGE statement to display a character string on the Message line. The

    default Message line is line two of the active window. You can change this through the use of

    the OPTIONS window.

    The message will remain on the screen until another MESSAGE statement is used. This

    means the only way to clear a message is to display another message of zero or more characters.

    Attributes: UNDERLINE REVERSE INVISIBLE BOLD

    BLINK NORMAL DIM

    THE ERROR STATEMENT:

    Syntax:

    ERROR display_list [ ATTRIBUTE (attribute list) ]

    Example:

    ERROR No Rows Found

  • 7/21/2019 Informix(Aj)

    45/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    45

    Use the ERROR statement to display a character string on the Error line. The defaultError line is the last line of the screen. You can change this through the use of the OPTIONS

    statement. The Error line is always relative to the screen, regardless of the number of windowsyou have open. The ERROR statement always displays text in reverse video and sounds the

    terminal bell.An error message remains on the screen until another key is pressed by the user

    Attributes: UNDERLINE REVERSE INVISIBLE BOLDBLINK NORMAL DIM

    THE DISPLAY STATEMENT:

    Syntax:

    DISPLAY message AT row, column

    [ ATTRIBUTE (attribute list) ]

    Example:

    DISPLAY Row Added. AT 22, 3 ATTRIBUTE (reverse)

    Use the DISPLAY statement to display a character string to a specific location on thescreen. With DISPLAY, you specify exactly where you want your message to be displayed by

    giving a row and column location. If no row and column location is specified, DISPLAY will

    display your message where the cursor is currently pointing.

    Attributes: UNDERLINE REVERSE INVISIBLE BOLD

    BLINK NORMAL DIM

    THE PROMPT STATEMENT:

    Syntax:PROMPT message [ ATTRIBUTE (attribute list) ]

    FOR CHAR variable[ HELP help-no ]

    [ ATTRIBUTE (attribute list)][ ON KEY (Key-list) ]

    statement . . .END PROMPT

    Example:

    PROMPT Are you sure? (Y/N) :FOR CHAR answervar

    The PROMPT statement not only displays a line of text, but waits for the user to reply.

    The users reply is stored in a variable. The default display for PROMPT is the first line of the

    window.

  • 7/21/2019 Informix(Aj)

    46/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    46

    The CHAR option When INFORMIX-4GL encounters a prompt statement,it will wait for the user to enter a response and press

    RETURN. If the CHAR option is used, the PROMPTstatement expects the variable to be defined as a single

    character, and will not wait for RETURN to be pressed.

    The HELP # option A Help number will find the numbered message created

    using mkmessage utility and displays it to the user

    when the Help key (CONTROL-W by default) ispressed.

    The ON KEY option The ON KEY option is used to define an action that willoccur when the key listed in the key-list is pressed.

    Attributes You can associate two sets of attributes with thePROMPT statement. The first attribute applies to the

    message; the second attribute is for the variable orusers response to the PROMPT statement.

    Attributes: UNDERLINE REVERSE INVISIBLE BOLDBLINK NORMAL DIM

    THE OPTIONS STATEMENT

    The OPTIONS statement can be used to change default values associated with somecommands. Defaults that can be changed include:

    ? The line messages are displayed to

    ? The line error messages are displayed on

    ? The location of user prompts

    The default lines on which the MESSAGE statement, PROMPT statement and theERROR statement display can be changed using the OPTIONS statement.

    eg. OPTIONS

    MESSAGE LINE FIRST + 2,

    ERROR LINE 23,

    PROMPT LINE LAST - 3

    ? The help keyBy default, the help key is CONTROL-W. The HELP KEY option allows you todefine a different help key.

    eg. OPTIONSHELP KEY CONTROL-B

    ? The location of menusThe MENU LINE option allows you to direct the menu lines to any lines of your

    current screen or window. Either of the reserved words, FIRST or LAST, can be used

    with MENU LINE. The values of FIRST and LAST are always relative to the current

    screen or window.

    eg. OPTIONSMENU LINE LAST - 1

  • 7/21/2019 Informix(Aj)

    47/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    47

    THE MENU STATEMENT

    A menu in an INFORMIX-4GL program can contain as many options as you need.

    Sample:

    MAINCALL main_menu()

    CLEAR SCREENEND MAIN

    FUNCTION main_menu()

    MENU MAIN MENU

    COMMAND Customer Go to the CUSTOMER menu

    CALL dummy()COMMAND Orders Add a new order

    CALL dummy()

    COMMAND Stock Go to the STOCK menu

    CALL dummy()COMMAND Reports Go to the REPORTS menu

    CALL dummy()

    COMMAND Exit Return to the operating system

    EXIT MENU

    END MENU

    END FUNCTION

    FUNCTION dummy()ERROR Function not yet implemented.

    END FUNCTION

    In the code above, the MENU keyword is followed by the menu title. This startsthe menu structure. From that point, the COMMAND keyword is used once for each option that

    appears on the menu.

    ? You may want to specify the menu name in uppercase so that it is easilydifferentiated from the menu commands.

    ? INFORMIX-4GL adds a colon (:) after the menu name and two spaces between eachcommand option. If the menu exceeds 80 characters, an ellipse () indicates that

    additional command options exist.

    ? The menu name (MAIN MENU) will be displayed to the left of the command optionswhen your menu is displayed.

    ? END MENU is a required syntax when you use the MENU statement

    ? The EXIT MENU statement terminates the menu statement.

  • 7/21/2019 Informix(Aj)

    48/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    48

    THE COMMAND CLAUSE

    The clause, COMMAND menu-option, displays the stated options as a choice to the useron a ring menu.

    EXIT MENU

    It terminates the MENU statement and executes the next line of code following the END

    MENU statement.

    The dummy function

    The dummy function uses an ERROR statement to display a message in reverse video on

    the last line of the screen, it will also ring the terminal bell.

    SHOW OPTION AND HIDE OPTION

    You can display subsets of menu options using SHOW OPTION and HIDE OPTION.

    The SHOW OPTION and HIDE OPTION statements can appear in a BEFORE MENUclause or in a COMMAND clause.

    THE BEFORE MENU CLAUSE

    The BEFORE MENU clause executes INFORMIX-4GL statements contained in the

    clause just before the menu is displayed. This makes it a logical place for the execution of HIDE

    OPTION and SHOW OPTION statements.

    eg.

    FUNCTION main_menu()MENU MAIN MENU

    BEFORE MENUHIDE OPTION ALL

    SHOW OPTION Query, Add, Exit

    COMMAND Query Query for a row in the customer table

    IF query_cust() = TRUE THENSHOW OPTION Next, Previous, Update, Delete

    ELSEHIDE OPTION ALL

    HIDE OPTION Next, Previous, Update, DeleteEND IF

    END MENU

    END FUNCTION

  • 7/21/2019 Informix(Aj)

    49/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    49

    THE COMMAND KEY

    If you prefer to provide your users with a one-stroke option, use the COMMAND KEY

    (key-list) menu-option clause to redefine which key should be pressed to execute the givencommand option. When a COMMAND clause includes a key list, the first letter of the option

    name no longer activates the option.

    eg. COMMAND KEY(T) sTates Go to the STATE menuCALL dummy()

    A HIDDEN COMMAND OPTION

    A hidden option can be created on a menu by not including an option name next to the

    COMMAND KEY clause.

    eg. COMMAND KEY (CONTROL-B)CALL dummy()

    If the user presses CONTROL-B, the function dummy will be called. The user has to

    know that this command option exists; it does not show up on the menu the way the otheroptions do.

    MULTIPLE MENUS

    It is quite common in INFORMIX-4GL to have one menu call another.

    eg.

    FUNCTION main_menu()MENU MAIN MENU

    COMMAND Customer Go to the CUSTOMER menu

    CALL cust_menu()NEXT OPTION Orders

    COMMAND Orders Add a new order

    CALL dummy ()

    . . .

    END MENU

    END FUNCTION

    FUNCTION cust_menu()MENU CUSTOMER

    COMMAND Query Search for a customer

    CALL dummy()

    COMMAND Next Go to the Next customer

    CALL dummy()

    COMMAND Exit Return to the Main menu

    EXIT MENU

    END MENU

    END FUNCTION

  • 7/21/2019 Informix(Aj)

    50/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    50

    PROCEDURAL LOGIC

    INFORMIX-4GL procedural logic statements are similar to those found in otherprogramming languages. They are used to guide the path of a program during its execution.

    IF STATEMENT:

    Syntax:

    IF expression THENStatement(s)

    END IF

    Example:

    IF prompt_answer MATCHES [Yy] THEN

    ERROR Customer will be deletedELSE

    ERROR Delete cancelled

    END IF

    An IF statement is an instruction to execute a statement conditionally. It involves a two-

    way logical choice. During program execution, when the test expression evaluates to TRUE,

    INFORMIX-4GL executes the statements following the keyword THEN and terminating with

    the keyword END IF or ELSE. With an ELSE clause, whenever the test expression evaluates to

    FALSE (or NULL), INFORMIX-4GL executes the ELSE clause statements. The ELSE clause is

    optional.

    IF WITHIN OTHER STATEMENTS

    Syntax:IF .... THEN

    IF ... THEN...

    END IFEND IF

    Example:

    IF state = CA THENIF zipcode MATCHES 940* THEN

    MESSAGE City is Redwood City.END IF

    END IF

    IF statements can be nested within other IF statements. A frequent mistake (generic

    syntax error) is to forget the END IF keywords or, in the case of nested IF statements, to fail tomatch each IF with an END IF.

  • 7/21/2019 Informix(Aj)

    51/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    51

    CASE STATEMENT:

    Syntax:CASE

    WHEN { expr / Boolean expr }....

    [ EXIT CASE ][ OTHERWISE ]

    statement(s)[ EXIT CASE ]

    END CASE

    Example:

    CASE

    WHEN answervar = YMESSAGE Answered Yes

    WHEN answervar = N

    MESSAGE Answered No

    OTHERWISEMESSAGE BAD Answer

    END CASE

    The CASE statement can be reduced to multiple IF statements. However, it is often more

    coherent to express a series of related choices in one statement.

    The CASE statement repeats the variable or expression once for each WHEN clause asillustrated above. This can be eliminated by using the variable or expression in the CASEstatement only once. The WHEN statement then checks the possible values for the given

    expression.

    The OTHERWISE clause is optional. It is triggered when all the preceding WHENclause conditions test FALSE. Statements made in the OTHERWISE clause execute if all the

    listed conditions fail.

    There is an implied EXIT CASE statement at the end of each sequence of statementsfollowing a WHEN clause. Thus, when conditions are met and statements associated with a

    WHEN clause execute, program control passes to the sequence of statements following the ENDCASE statement. You do not need an explicit EXIT CASE.

  • 7/21/2019 Informix(Aj)

    52/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    52

    WHILE LOOP

    Syntax:WHILE Boolean expression

    Statement(s)[ EXIT WHILE ]

    [ CONTINUE WHILE ]END WHILE

    Example:

    WHILE boss_in_office = TRUECALL act_busy() RETURNING boss_in_office

    END WHILE

    CALL sneak_out()

    Use a WHILE loop to execute a statement or group of statements for as many times as

    the stated Boolean condition tests TRUE.

    The optional statement EXIT WHILE moves program control to the first statementfollowing END WHILE.

    The optional statement CONTINUE WHILE interrupts the sequence and causes program

    control to return to the top of the sequence and to test the Boolean expression.

    If the Boolean expression is FALSE, then the program control skips to the first statement

    after the END WHILE.

    FOR LOOP:

    Syntax:

    FOR integer_variable = integer_expression to integer_expressionSTEP integer_expression

    Statement(s)[ CONTINUE FOR ] ....

    [ EXIT FOR ] ...END FOR

    Use the FOR loop to specify a number of times an iteration should occur. If you use the

    keyword STEP with an integer expression, the loop is incremented in steps of the value youstate.

    Since integer expression can be a variable, you can set the count dynamically.

  • 7/21/2019 Informix(Aj)

    53/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    53

    FORMS

    CREATING A DEFAULT FORM

    To create a default form, select Form from the INFORMIX-4GL menu. The Generate

    option of the FORM menu will take you through the following steps to create a default form.

    CHOOSE DATABASE >>NEW FORM >>

    CHOOSE TABLE >>Table-selection-complete / select-more-tables

    INFORMIX-4GL will then compile the form into a usable state.

    MODIFYING A DEFAULT FORM

    When you select the Modifyoption from the FORM menu, you are presented with a list

    of forms that can be modified. Highlight the form you want to work with and press RETURN.

    COMPILING A FORM SPECIFICATION

    Once you have modified the screen section to the desired appearance, the Programmers

    environment presents you with the MODIFY FORM menu. There are three options.

    Compile - Translates the form specification file into a format that INFORMIX-4GLcan use.

    Save-and-exit - Saves the changes you have made, but will not compile the form.

    Discard-and-exit - Discards any changes you have made during your editing session.

    DISPLAYING FORMS AND WINDOWS

    OPEN FORM STATEMENT

    Syntax: OPEN FORM form-name FROM form-file

    eg. OPEN FORM cust_form FROM cust_form

    The OPEN FORM statement is used to associate an INFORMIX-4GL form name with a

    previously compiled form.

  • 7/21/2019 Informix(Aj)

    54/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    54

    Form-name is the name you want to assign to the form for use in your program. It is anidentifier for the form. It is quite common to have form-name and form-file be the same name,

    but it is not required.

    Form-file is the name of the previously compiled form that was created from the FORMmenu.

    DISPLAY FORM STATEMENT

    Syntax: DISPLAY FORM form-name

    eg. OPEN FORM cust_form FROM cust_form

    DISPLAY FORM cust_form

    The DISPLAY FORM statement is used to display a form on the screen. Before a formcan be displayed, it must first be opened using the OPEN FORM statement.

    CLOSE FORM STATEMENT

    Syntax: CLOSE FORM form-name

    eg. CLOSE FORM cust_form

    The CLOSE FORM statement is used to release the memory associated with a form. It

    does not clear the form from the screen.

    Sample Program:

    MAINCALL prog_init()

    CALL main_menu()CALL prog_wrapup()

    CLEAR SCREENEND MAIN

    FUNCTION prog_init()

    OPEN FORM custform FROM custformEND FUNCTION

  • 7/21/2019 Informix(Aj)

    55/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    55

    FUNCTION main_menu()MENU MAIN MENU

    COMMAND Customer Go to the CUSTOMER menuCALL cust_menu()

    NEXT OPTION Orders

    COMMAND Orders Add a new orderCALL dummy()

    COMMAND Exit Return to the operating systemEXIT MENU

    END MENUEND FUNCTION

    FUNCTION cust_menu()

    DISPLAY FORM custformMENU CUSTOMER

    COMMAND Query Search for a customer

    CALL dummy()

    COMMAND Next Go to the next customerCALL dummy()

    COMMAND Exit Exit to MAIN MENU

    EXIT MENU

    END MENU

    CLEAR SCREEN

    END FUNCTION

    FUNCTION dummy()ERROR Function not yet implemented

    END FUNCTION

    FUNCTION prog_wrapup()CLOSE FORM custform

    END FUNCTION

  • 7/21/2019 Informix(Aj)

    56/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    56

    THE INPUT STATEMENT

    The process of entering information into the database has two basic steps.

    1. Inputting information into program variables2. Inserting the data in those program variables into the database

    Since there are two basic steps, keywords that handle this transfer of information: the

    INPUT statement and the INSERT statement.

    The INPUT statement is used to retrieve information from the user via the screen, andtransfer it to the program variables. The INPUT statement:

    ? Initialize the program variables to NULL by default

    ? Turns control of the program over to the user

    ? Displays any default values which may have been specified by the DEFAULTattribute of a form specification file

    ? Lets the user enter information into the fields of the form

    ? Transfers the information automatically into the program variables as the user leaveseach field

    ? Waits for a signal from the users that they have finished their data entry

    Before using the INPUT statement, you must have satisfied a few requirements:

    ? There must be a form open and displayed

    ? There must be a program variable assigned to each field in which you are going toallow data entry

    INPUT PROGRAM VARIABLE

    Syntax: INPUT program-variable FROM field-list

    Example: INPUT gr_customer.fname,

    gr_customer.lname,gr_customer.company,

    gr_customer.address1,

    gr_customer.address2,gr_customer.city,gr_customer.state,

    gr_customer.zipcode,gr_customer.phone

  • 7/21/2019 Informix(Aj)

    57/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    57

    FROM fname,lname,

    company,address1,

    address2,city,

    state,zipcode,

    phone

    The program variables listed have been defined in an INFORMIX-4GL module, and fieldlist comes from the ATTRIBUTES section of a form specification file. For every program

    variable listed in the INPUT statement, there must be a corresponding field in the FORM, and

    they must be in the same sequence. The cursor will move in field-list order.

    The INPUT statement takes the information from the form and puts it into a

    corresponding program variable as the user goes from field to field.

    EXITING FROM THE INPUT STATEMENT

    The Default Condition Pressing the RETURN key after entering data in the last field of

    the form automatically causes the program to continue.

    The ACCEPT Key If the user presses the ACCEPT key (ESC by default), theprogram will continue to the next line of code.

    The INTERRUPT Key When the INTERRUPT key is pressed, the program proceeds to

    the statement immediately following the END INPUTstatement. Any clauses within the INPUT statement will be

    skipped. This effectively aborts the INPUT statement.

    THE INPUT STATEMENT USING THE BY NAME SYNTAX

    Syntax: INPUT BY NAME program-variable.*

    Example: INPUT BY NAME gr_customer.*

    The program-variable is a record that has been defined in an INFORMIX-4GL module.

    Using the syntax shown in the above requires that the names of the variables defined in thegr_customer record must be the same as those in the field list of the form. The cursor will gothrough the fields based on the order of the DEFINE statement for the program variables.

  • 7/21/2019 Informix(Aj)

    58/69

    INFORMIX

    Ordnance Factories Institute of Learning, Ambajhari

    58

    THE INPUT STATEMENT BY NAME WITH THRU

    Syntax: INPUT BY NAME program-variable THRU program-variable

    Example: INPUT BY NAME gr_customer.fname THRU gr_customer.phone

    Program variables: DATABASE stores

    GLOBALS

    DEFINE gr_customer

    RECORD LIKE customer.*

    END GLOBALS

    This method of using INPUT allows you to enter specific fields while still using the BY

    NAME syntax.

    INPUT STATEMENT CLAUSES

    ATTRIBUTE (attribute-list) This is an optional keyword you can use to specifyscreen input attributes.

    HELP help-number This is used to specify a help message. The messageassociated with the help number should apply to the

    INPUT statement as a whole.

    BEFORE INPUT This clause is executed before the control of the programis turned over to the end user

    AFTER INPUT The statements following the keywords will