230
ikB~;dze lkexzh STUDY MATERIAL COMPUTER APPLICATIONS & INFORMIX vk;q/k fuekZf.k;kWa f’k{k.k laLFkk,Wa esnd ORDNANCE FACTORIES INSTITUTE OF LEARNING OFILMK 0 MEDAK

COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

  • Upload
    others

  • View
    17

  • Download
    0

Embed Size (px)

Citation preview

Page 1: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

ikB~;dze lkexzh STUDY MATERIAL

COMPUTER APPLICATIONS & INFORMIX

vk;q/k fuekZf.k;kWa f’k{k.k laLFkk,Wa esnd ORDNANCE FACTORIES INSTITUTE OF LEARNING

OFILMK

0MEDAK

Page 2: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK 1

vk;q/k fuekZf.k;kWa f’k{k.k laLFkku] esnd

fiz; izfrHkkfx;ksa] vk;q/k fuekZf.k;kWa f’k{k.k laLFkku] esnd esa eSa vki lHkh dk gkfnZd Lokxr djrk gwWa A vki 36 gQrs gekjs lkFk jgsaxs ftl nkSjku vkidks izf”k{k.k dk;Zdze ds vuqlkj fofHkUu izdkj ds izf”k{k.k fn, tk,WaxsA ;g gekjk iz;kl jgsxk fd mDr izfa”k{k.k ds nkSjku vkidks fn, tkus okys izf”k{k.k lkexzh iw.kZr% ykHknk;d gks A bl izf”k{k.k laLFkku }kjk nh xbZ ikB~; lkexzh vkidh dq”kyrk] dk;Z lk/kd Kku ,oa vfHkofRr esa cnyko ykus esa lgk;d jgsxh A lkFk gh lkFk gekjk ;g Hkh y{; gksxk fd vki Hkfo’; dh pqukSfr;ksa dk lkeuk djrs gq, dk;Z dks lQyrk ls fu’ikfnr djus esa leFkZ gks A ;g gekjk iz;kl jgsxk fd ge laxBu ds vko”;drkuqlkj vkidks lqfo/kk iznku dj lds A ;g gekjk lkSHkkX; gS fd ge lHkh fo’k;ksa dh vfrfjDr tkudkjh ls vkidks voxr djk, A vki bl laca/k esa vkids dkslZ funs”kd ;k dkslZ leUo;drkZ ls laidZ dj ldrs gSaA ge vk”kk djrs gSa fd vkidks izf’k{k.k ds nkSjku izkIr xq.krkiw.kZ izf’k{k.k ls laxBu ykHkkafUor gksxh A vk”kk djrs gS fd vki fuekZf.k;ksa dks lalkj ds cgrjhu fuekZrk dsUnz cukus dk vFkd iz;kl djsaxs A eSa vki lHkh dk lq[kn] jkspd ,oa vkuUne; okl ds fy, dkeuk djrk gwWa A g0@& Izk/kku funs’kd

Page 3: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK 2

ORDNANCE FACTORIES INSTITUTE OF LEARNING, MEDAK

Dear Participants, I extend my warm welcome on behalf of Ordnance Factories Institute of Learning, Medak. You will be with us for 36 weeks, undergoing various Training Programmes as per schedule. It is our endeavour to see that the Effective Training inputs are provided to you during the above period. The inputs, this institute shall provide are meant to enhance your skill, job knowledge and bring forth change of attitude. It is also our aim to enhance your performance, and squarely face the challenges ahead. Our intention is to work as facilitators, for you to meet the organisational needs towards that and we shall be glad to provide any additional information you may require. Your Course Director / Course Co-ordinator will help you in this regard. We hope that the organisation shall be benefited greatly by the quality of inputs, you receive during training. It is expected that you will strive to make our factories a world class manufacturing centers. I wish your stay most comfortable, interesting and enjoyable.

Sd/- PRINCIPAL DIRECTOR

Page 4: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK 3

NOTE

NOTHING IN THIS BOOKLET MAY BE TAKEN AS CONVEYING ANY SANCTION OR

AUTHORITY OR MAY BE HELD TO SUPERCEDE ANY STANDING RULE OR ANY ORDER OF

GOVERNMENT OF INDIA WITH WHICH IT MAY BE AT VARIANCE.

Page 5: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK 4

INDEX

1. BASICS & WINDOWS O.S............................................................................................................... 5

2. WINDOWS O.S. ................................................................................................................................. 10

3. MICROSOFT WORD ...................................................................................................................... 14

4. MICROSOFT EXCEL....................................................................................................................... 35

5. MICROSOFT POWERPOINT .......................................................................................................... 54

6. MICROSOFT ACCESS .................................................................................................................... 68

7. RDBMS CONCEPTS ........................................................................................................................ 82

8. STRUCTURED QUERY LANGUAGE (SQL) ............................................................................... 88

9. DATABASE MANAGEMENT....................................................................................................... 105

10. WORKING WITH FORMS .......................................................................................................... 119

11. ACE REPORT WRITER.............................................................................................................. 122

12. INFORMIX-4GL ............................................................................................................................ 138

13. PARTS OF AN APPLICATION ...................................................................................................... 147

14. DATABASE ACCESS AND REPORTS......................................................................................... 170

15. THE USER INTERFACE .................................................................................................................. 175

16. OFB COMMNET............................................................................................................................ 229

Page 6: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

1. BASICS & WINDOWS O.S

1. COMPUTER FUNDAMENTALS Introduction Computer is an Electronic device which COMPUTEs data/Instructions (Commands). The term COMPUTE includes the following major functions.

1. Accepting commands/data(INPUT) 2. Performing necessary calculations(PROCESSING) 3. Finally producing the results in the required format. (OUTPUT)

Functional Block Diagram of Computer (FBD) FBD shows the various main functional units of Computer. The diagram is as follows:

INPUT OUTPUT

MU

CU

ALU

Central Processing Unit(CPU) FBD contains mainly three units. Those are

A. Input Unit B. CPU(Central Processing Unit) C. Output Unit

INPUT UNIT It is an electronic device used to enter or feed data to the Computer. User can communicate with Computer by using an Input device.

OFILMK 5

Page 7: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK 6

Example for Input Devices.

1. Keyboard 2. Mouse 3. Card Reader 4. Scanner 5. Micro phone 6. Digital Camera 7. Web Camera 8. Floppy Disk 9. Hard Disk 10. CD/DVD 11. DAT Media (DAT – Digital Analog Tape)

CENTRAL PROCESSING UNIT CPU mainly consists of 3 sub-units. Those are 1. MU (MEMORY UNIT): MU is used to store the data/commands. 2. CU (CONTROL UNIT): CU controls and co-ordinates all operations of computer. 3. ALU (Arithmetic and Logical Unit): ALU performs all operations of Computer and results are

sent to the Output Unit. OUT UNIT

Output Unit is an electronic device that enables output data in the human understandable way. The output can be displayed, printed or stored. Example for Output 1. Monitor (VDU – Visual Display Unit) 2. Printer 3. Plotter 4. Card punching device 5. Multimedia speakers. 6. Web Camera. 7. Floppy Disk 8. Hard Disk 9. CD/DVD(CD – Compact Disk, DVD – Digital Versatile Disk) 10. DAT Media.(DAT – Digital Analog Tape)

More about CPU

• CPU is the Heart of the Computer since the storage and processing is done in the CPU • Speed & performance of Computer depends on the type of CPU.

Page 8: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK 7

• CPU types are o 8088 o 80286 o 80386 o 80486 o 80586 or Pentium – I o Pentium – II o Pentium – III o Pentium – IV

The latest CPU now a days available in the Market is Pentium –IV with 3.0 G Hz HT (Hyper Threading Technology). Various CPU manufacturing companies are

• Intel • Motorola • Zilog

Memory Organisation

- Memory is used to store data - Data is stored in memory in form of 0s and 1s - These 0s and 1s are Binary Digits or BITS - 8 Bits are needed to store one character(letter, digit or symbol) - Memory consists of number of Memory locations. Each memory location is given a

separate number called Memory Address - Each memory Location can store some fixed number of bits. - The Number of bits for a memory location is called its Word Length - Word length is in the order of either 8 bits, 16bits, 32 bits or 64 bits. - Memory Measuring units

8 bits = 1 Byte (1 Character) 1024 Bytes = 1 Kilo Byte (KB) 1024 KB = 1 MB (Mega byte) 1024 MB = 1 Giga Bytes (1 GB) 1024 GB = 1 Tera Byte. (1 TB)

Types of Memories According nature OF STORAGE, memory is classified into two types.

1. Main Memory(Primary Memory or System Memory) 2. Secondary Memory(Auxiliary Memory)

Main Memory Main Memory is kept inside the CPU. It has the property of VOLATILE. Volatile means when the power is cut off the contents of the Main Memory will be erased or lost. Hence only temporary storage is possible by using Main Memory.

Page 9: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK 8

Type of Main Memory

1. RAM (Random Access Memory) 2. ROM (Read Only Memory)

RAM (RANDOM ACCESS MEMORY) RAM is called System Memory. The speed of Computer is depending upon the capacity of RAM. RAM capacities are starting from 32 MB, 64 MB, 128 MB, 256 MB, 512MB, 1 GB and up to 4 GB and etc. While purchasing a Computer we have to specify the capacity of RAM. ROM (READ ONLY MEMORY) We can only read data from ROM. Writing will be done by the manufacturer. ROM consists of Boot Strap programme that is used to start the Computer. Secondary Memory It is a separate Memory Device. Secondary Memory has got the property of Non-VOLATILE. Non-VOLATILE means even though the power is cut off, the contents of the secondary memory will NOT be erased or lost and hence data will be stored permanently in Secondary Memory. Secondary Memory Devices

1. Floppy Disk – Capacity 1.44 MB 2. Hard Disk - Capacity 120 GB or more 3. CD(Compact Disk) – Capacity 650 MB to 700 MB 4. DVD – Capacity 4 GB (DVD – Digital Versatile Disk) 5. DAT – Capacity 4 GB to 16 GB (DAT – Digital Analog Tape)

Types of Computers 1. Analog Computers 2. Digital Computers 3. Hybrid Computers

Types of Digital Computers

1. Micro Computers 2. Mini Computers 3. Main Frame Computers 4. Super Computers

Micro Computer

Micro Computers are single user systems (Computers). It means at a time only one user can operate the Computer. Hence these are also called Personal Computers or simply PCs

Types of PCs 1. P.C(Personal Computer) – CPU – 8088 2. PC-XT(Personal Computer – Extended Technology) – CPU – 80286 3. PC-AT(PC – Advanced Technology) – CPU – 80386 or 80486 4. Super AT – CPU – Pentium – I, Pentium –II, Pentium – III or Pentium – IV

Page 10: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK 9

Multi-user Systems

Mini, Mainframe and Super computers are Multi-user systems. It means more than one user can operate the Computer at a time. In a Multi user system there is a single CPU called Central C.P.U or the Server. The server is connected by number of terminals. A Terminal consists of only Input & Output devices. The data storage and processing will be done at the central CPU (Server).

Computer Hardware

The physical devices of computer are called it’s hardware. Example for Computer hardware devices

1. Keyboard 2. Monitor 3. Mouse 4. Printer and etc.

Software

A set of programmes that are used to functioning the hardware are called software. Software is of mainly two types: 1. System Software 2. Application Software.

System Software

A Software that is used to run (operate) and maintain the Computer system is called System Software.

Ex.: Operating System Application Software

A software that is used to performs (do) a particular user task (job) is called application software or package.

List of packages 1. Microsoft Word – Word processing package 2. Microsoft Excel – Spread sheet package. 3. Microsoft PowerPoint – Presentation package 4. Microsoft Access – DBMS package 5. Microsoft Outlook – Computerized dairy/Calendar 6. DBMS package : FoxPro, FoxBASE, dBase (DBMS Database Management System) 7. RDBMS package: Oracle, Sybase, Ingress, INFORMIX (RDBMS – Relational Database

Management System) 8. Designing packages : Auto CAD, LISP, UG (Uni Graphics) 9. DTP packages : Corel draw, Page make, Photo shop 10. Accounting Packages: Ex, Wings, Tally, Profit – etc.

Page 11: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK 10

2. WINDOWS O.S. Operating System (OS)

Operating System (O.S) is a System Software which controls, manages and coordinates all operations of Computer. Without Operating system we can NOT operate Computer. Examples for Operating System 1. MS-DOS(Microsoft Disk Operating System) 2. WINDOWS 95 3. WINDOWS 98 4. WINDOWS NT 5. WINDOWS 2000 6. WINDOWS 2003 7. WINDOWS XP 8. SCO-UNIX 9. LINUX 10. MACINTOSH

WINDOWS XP

WINDOWS XP is an Operating System developed by Microsoft Corporation USA. It is mainly used for Desktop PCs. (Micro Computers)

Windows O.S Terminology 1. WINDOW: A window is a part of the screen used to run an application. 2. APPLICATION: A Software programme used to do a particular job is called an application.

The terms Program and Application can be interchangeable. Some ex for windows application a. Notepad b. WordPad c. Paint d. Calculator e. MS-office (WORD, EXCEL, Access etc.)

3. ICON: A small graphic symbol used to represent an application/command/file/folder etc. is called an icon.

4. DESKTOP: The opening screen of Windows O.S is called Desktop. 5. GUI (Graphical User Interface) WINDOWS is a GUI Operating system. In GUI environment

each command/operation is represented by using Icons. Just click on a an icon to do an operation.(We need not type a command)

The Input device, Mouse, is a must to work with any GUI software.

Page 12: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK 11

Parts of a WINDOW (Notepad window)

I. Title Bar: It displays File name and the Application name. If the file is not saved it displays as

Untitled

II. Menu Bar: It contains Menu options like File, Edit, and View etc.

III. Vertical Scroll Bar: To see the data vertically up or down words.

IV. Horizontal Scroll Bar : To see data horizontally(left to right)

V. Minimise button: To minimize the window and place it on the Tasks bar. Just click on the Application to open it from the tasks bar.

VI. Maximise button: It is used to maximize a particular window so that it occupies the entire Desktop. The running programmes will be send back. Once you maximize a window, a Restore button will be appeared in place of Maximize button.

VII. Restore button: It is used to restore the Window to its previous size

VIII. Close button: to close a programme/Window.

Windows Accessories

Windows Accessory is a standard program used to do some particular task. Some commonly used Windows accessories are

1. Notepad: Used to create test files. (.TXT file) 2. WordPad: Used to create document files(.DOC files) 3. Paint : Used to create picture file (.BMP file BMP – Bit map Image ) 4. Calculator: Used as a desk calculator.

Copying data from one location to another location (Blocking Technique)

1. Select the to copy by means of dragging mouse. 2. Click Edit Copy from the Menu bar 3. Place the cursor where you want to paste the data. 4. Finally Click Edit Paste to paste the data.

File Management in Windows O.S

File: File is a collection of related data stored in Computer Memory. The physical media for storing files is Hard Disk. File Name: It is a name given to the data stored in Computer memory. File/Folder structure

Folder (Directory): For easily maintaining files in Hard Disk, Hard disk is divided into group of racks. Each rack is called a Folder. A Folder is a separate place in a disk(any Secondary Memory Disk, usually Hard disk) to store files separately. A Folder consists of either Files or Sub-Folders. A Sub-Folder consists of either files or even sub-folders. The File/Folder structure is maintained as a TREE structure in Windows Operating System.

Page 13: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK 12

My Computer My Computer is File Manager used to create and maintain Files/Folders. The My Computer icon is available on the Desktop. Creating a Folder

1. Open My Computer 2. Open the Disk Where you want to create a Folder.(Usually Hard Disk) 3. Click on File New Folder from the Menu Bar, a new folder will be created with a

temporary name. 4. Type the name of the Folder and press ENTER key.

Creating Files in a Folder

1. Open any application and type the data. 2. Click on File Save from the Menu bar 3. Type the File Name 4. At Save in option get the Folder name 5. Finally Click Save.

Copying files 1. Open Source folder and select files to copy 2. Click on Edit Copy from the Menu Bar 3. Open the Destination Folder 4. Finally Click on Edit Paste from the Menu bar.

Changing name of File/Folder

1. Select File/Folder to change the name 2. Click on File Rename from the Menu bar 3. Type the New name and press Enter key

Deleting File/Folder

1. Select File/Folder to delete it 2. Click on File Delete from the Menu bar. 3. Click on YES for confirmation then the selected File/Folder will be deleted and stored in the

Recycle Bin

Recycle Bin

Recycle Bin is the system folder which stores all the deleted files so that the un-deletion (restore) of files can be done later from the Recycle Bin

Un-deleting (Restoring)

1. Open the Recycle Bin 2. Select the Files to undelete (restore) 3. Click on File Restore from the Menu bar then the selected files will be restored back into

their original Folders.

Page 14: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK 13

Deleting files permanently

1. Open the Recycle Bin 2. Select the Files to delete permanently 3. Click on File Delete from the Menu bar. 4. Click YES for confirmation then the selected files will be deleted permanently.

Note: Once you delete files from the Recycle Bin then there is no way to get back the deleted file. Control Panel Control Panel is an application consists of various programmes/applications that are used to change the software and hardware settings of windows operating system. Some important applications in Control panel are

1. Date and Time: It is used to change the system date and time. Inside the Computer, system date and time are maintained by using a battery backup. The steps to change system date and time are

b. Open Control panel c. Open date and Time icon d. Chang the required date and time e. Finally Click OK

2. Display: It is used to change the appearance of the Desktop like wall paper, background, Screen Saver etc. The steps to change display settings are

a. Open Control panel b. Open Display icon c. Click on Desktop tab and change the required background. d. Click on the Screen Saver change the required Screen Saver. e. Finally Click OK.

Page 15: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK 14

3. MICROSOFT WORD

Introduction

MS-WORD is a word processing package, mainly used to enter data into Computer's memory and take the better print out of it. It is a part of MS-Office package developed by Micro Soft Corporation U.S.A.

Features of MS-WORD

1. Word wrapping: - It is the phenomena of aligning the data automatically within left and right margins as you go on entering the data. Hence we need not press Enter key at the end of each and every line while feeding data in MS-WORD. We have to press Enter key to change the paragraph only.

2. On screen formats: - On screen formats include margins (left, right, top & bottom), line spacing, paper size & etc. These will be automatically set as and when you open a new file. It is possible to change anyone of these on screen formats.

3. Automatic spell checking: - MS-WORD consists of American based English dictionary using this we can check the spelling of data. MS-WORD will automatically check the spelling as you are entering the data.

4. Improved print functions: - Printing can be done with selected pages. High quality output can be obtained by using Ms-word.

5. Macros: - A Macro is a name used to represent number of characters or operations so that some short hand functions can be done by using this macros.

6. Mail Merge: - Mail merge is the process of sending same information to different addresses.

7. Working with the Net: - Data entered in the MS-WORD can be saved as an HTML document (Hypertext mark up language), which can be viewed in the Internet.

Opening MS-WORD

Usually MS-WORD will be opened by slicking Start button and pointing to programs or other wise if you system consists of Office Short cut tool bar, you can directly click on Microsoft Word icon to open it. The usual steps to open MS-WORD are as follows.

1. Click start button and point to programs

2. From programs select Microsoft Word. Then the opening window of MS-WORD will be displayed as shown in the next page.

Note: The MS-Office package should be installed in your system in order to open MS-WORD. If MS-Office package is installed and Word is not available in the Programs list then you search it in the Programs for it's shortcut

Page 16: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

If your

Word screen will not display tool bars, select the required tool bars by selecting View -> Tool Bars from the Menu bar.

Page setup in Ms-Word

1. Select File followed by page setup from the menu bar then page set up dialogue box will be displayed as follows.

2. At Margins tab enter the required margins. 3. At Paper size tab select the required paper size and orientation 4. Finally click [OK]

OFILMK

15

Page 17: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

16

S hortcut keys

Shortcut key Purpose Ctrl + 0 To open an existing file. Ctrl + S To save a file. Ctrl + N To open a new file. Ctrl + P To print a file. Ctrl + Z To undo the recently done operation..Ctrl + X To Cut the selected data.Ctrl + C To copy the selected data into Clip Board Ctrl + V To Paste the data Ctrl + A To select all the data.Ctrl + F To find out required data(Searching) Ctrl + H To Find & Replace data Ctrl + G To go to a particular page. Ctrl + B To apply/delete Bold format to text or

numbers. Ctrl + I To apply/delete Italic formatting to text or

number Ctrl + U To apply/delete underling to text or data. Ctrl + ENTER key To insert a page break.Ctrl + Shift + F To select a different font name Ctrl + Shift + P To enter the font size. F7 To invoke Spelling & Grammar checking Alt+F4 To close any active window.Alt + F8 To Activate Macro dialogue box. Alt + Shift + 0 To mark a table of contents Entry.Alt + Shift + P To get the Page No. Ctrl + 1 To apply single line Spacing Ctrl + 2 To Apply double line spacing Ctrl + L To apply Left Justification(alignment) Ctrl + R To apply Right Justification(alignment) Ctrl + E To center align the data.

Some of the above short cuts keys can be applicable in the other office family packages like, MS-Excel & MS-Access, Power point etc.

Saving the file in Ms-Word

After entering all the data we have save the file for later use, the steps to save the file as follows.

1. Select File followed by Save from the menu bar.

2. If you don't specify the file name word asks for file name.

3. At Save in option select the folder to save the file in it.

4. Finally type the name of the file at the File name option and select |Save|.

Page 18: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

17

Printing a file in Ms-Word

1. Select File followed by Print from the menu bar then the Print dialog box will be displayed as follows.

2. At the Page range option, enter the pages to be printed. 3. At Number of copies option, enter the number of copies to be printed at a time. 4. Make the printer as ON LINE and finally select |OK|.

Opening a file in Ms-Word

1. After opening MS-WORD, select File followed by Open form the menu bar. 2. At Look in option specify the folder name where your file exists. 3. Click on the particular file name and finally click |Open|

Headers & Footers in Ms-Word

A. HEADER: - The data placed in the header will be printed on the top of every page. The header margin will always be included in the top of margin. Header or footer can be seen in the page layout view only.

B. FOOTER: - The data placed in the footer will be printed at the bottom of every page. Footer margin will always be included in the bottom margin.

Steps to specify header and footer are as follows. 1. Select View followed by Header and Footer from the menu bar. Then the Header

and Footer Tool Bar also will be activated. 2. At the Header portion type the header. 3. Click on Switch between Header and Footer Icon from Header and Footer tool bar. 4. Specify the Footer message. 5. Finally click outside to close Headers and Footers.

Page 19: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

18

Finding and replacing data in Ms-Word

1. Place the cursor form where you want to find out the data. 2. Select Edit followed by Replace from the menu bar. Then the find and replace

dialog box will be displayed as follows.

3. At Find what option type the data to be finding out. 4. At Replace with option type the word to be replaced. 5. Click Find Next to find out the next occurrence of the word. 6. Click Replace to replace the current occurrence of the word and find out the next

occurrence of the word. 7. Click Replaces All to replace all occurrence of the word with specified data. 8. Finally click Close.

Options with Find and Replace

Click M logue box to display more options. The various ore from the Find Replace diaoptions are as follows.

1. the search will become case sensitive that Match case: - If this is selected thenmeans if you type lower case at find what option then the word will search for lower case data only and vase - versa.

2. Find whole words only: - If it is selected only whole words will be searched not part of the word.

3. Use wild cards: - If it is selected we can apply wild characters like * &? And etc., so that the word will search accordingly.

4. Sounds like: - If it is selected, we can search the words, which gives same sound even though if they are spelled differently.

Ex: - Deva, Diva & deeva etc.

5. Find all word forms: - If it is selected the three forms of the word will be searched.

Ex: - write, wrote, written.

Page 20: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

19

Various views in MS-WORD

1. Normal view: - It is the preset view used for all-purpose like type editing, and formatting text. In edit view no pictures will be displayed, headers & footers also will not be displayed. But data editing will be done quickly. To switch normal view select Normal on the View menu.

2. Page layout view: - It is the widely useful view. We can see how objects will be headers and footers, for adjusting margins and for working with any drawing objects and frames. To switch to page layout view, click Page layout on the View menu.

3. Online layout view: - This layout is useful while working with long documents. We can easily read the text, which appears larger and wraps to fit the window. By default, online layout view includes a resizable navigation pane called document map.

4. Outline view: - Outline view makes it easy to look at the structure of a document to move, copy and reorganize text by dragging headings, In outline view, you can collapse a document to see only the main headings, or you can expand it to see the entire document. To switch to outline view, click Outlines the View menu.

5. Master document view: - A master document makes it easier to organize and maintain a long document, such as a multiparty report or a book with chapters. Use master document view to group several word documents into one master document. You can then make changes to the long document such as adding an index or table of contents or creating cross-references-without opening each of the individual documents. To switch to master document view, click Master document on the View menu.

Activating Tool bars

1. Select View followed by Tool Bars from the menu bar 2. Then it displays the list of Tool bars. 3. Select the required tool bar by clicking on it.

Inserting page numbers at Header/Footer

1. Select Insert followed by Page Number from the menu bar. Then the dialog box will be displayed as follows.

Page 21: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

20

2. Select the Position and Alignment of the page and finally select [OK] Inserting

System Date and Time

1. Place the cursor where you want to insert the date and time 2. Select Insert followed by Date and Time from the menu bar 3. Select the required format and finally select [UK]

Inserting Auto text.

Auto text will be automatically displayed above the line as and when you type it. We can also add any text as auto text. The steps are as follows.

1. Select Insert followed by Auto text. .from the menu bar 2. From the displayed options select Auto text. Then the dialog box will be

displayed as shown below.

3. Type the required auto text at the given box. 4. Click Add and finally select [OK]

The Function key F3 is used to insert the entire auto text data as and when it is displayed above the line.

Inserting a Special Symbol

1. Place the cursor where you want to insert the symbol. 2. Select insert followed by symbol from the menu bar. 3. Select the required symbol from the required font finally click on [Insert] followed by pose.

Page 22: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

21

Inserting Comments

A comment is an extra data that is added to a word/text Comments will not be printed. The steps to Inserting a Comment are as follow:

1. Select the data to insert comment for that.

2. Select Insert followed by Comment from the menu bar then the Comment dialog box will be displayed down. Type the comment and close.

Inserting a Footnote/Endnote

Footnote is a text, which will be displayed at the bottom of the particular page in a document. Endnote is a text, which will be displayed at the end of the last page in a document. The steps for inserting Footnote/Endnote are as follows.

1. Select insert by Footnote from the Menu Gar then the dialogue box will be displayed as shown below.

2. At the Insert option select either Footnote or End note and click [OK]

3. Type the text in the given region and finally click the mouse outside to close.

Inserting a Clip Art

Clip art is a picture which is supplied along with the Office package. The steps to insert a clip art are as follows.

1. Select Insert followed by Picture from the Menu bar.

2. Select Clip Art from the displayed options. Then the dialogue box will be displayed (as shown in the next page).

3. Select the required picture and click Insert followed by Close.

Page 23: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Formatting Data

Formatting data includes the following. 1. Increasing or decreasing the character size(Font size) 2. Applying a font(a Font is a style of text or data) 3. Changing the color of text and etc.,

The steps for formatting are as follows: -

1. Select the data to be formatted by means of dragging with the mouse. 2. Select Format followed by Font from the menu bar. 3. Then the Font dialog box will be displayed as shown below.

OFILMK

22

Page 24: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

23

4. Select the required parameters and finally click [OK]

Formatting paragraph

Paragraph formatting includes paragraph alignments (left, center, right), line spacing and etc. The steps are:

1. Select the paragraph to formatted 2. Select Format followed by Paragraph from the menu bar. 3. Select the required alignment and finally select [OK]

Applying Bullets & Numbering

A bullet is a special symbol which will be placed at the beginning of a paragraph. We can also apply numbers for paragraphs. The steps are as follows.

1. Select the Paragraphs to apply Bullets/Numbers. 2. Select FORMAT followed by bullets and Numbering from Menu Bar then

it's dialogue box will be displayed as follows

3. At the Bulleted tab select the required bullet or at Numbered tab select the required numbered style and finally click [OK].

Applying Borders and Shading

We can apply any boarders or Shading to data with different styles. The steps are as follows. 1. Select the data to which to apply boarder or shading. 2. Select Format Borders and Shading the dialogue box

will be displayed (as shown in the next page) 3. Select the required boarder at Borders tab. 4. AT Page Borders tab we can select required page boarder also. 5. At Shading tab select the required shading style and finally select [OR]

Page 25: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Making News paper columns

Data typed in MS-WORD can be changed as news papers columns. The steps are as follows.

1. Select the paragraphs to convert into columns. 2. Select Format Columns from the menu Bar then the columns dialogue box

will be displayed as follows.

3. Select the required number of columns at the Presets option and click [OK]

Drop cap

Drop Cap is a BIG letter that will be displayed at the beginning of a paragraph. The steps for Drop cap are as follows.

1. Place the cursor in the paragraph to which you apply Drop cap.

2. Select Format Drop cap from the menu bar, the dialog box will be displayed as follows.

OFILMK 24

Page 26: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK 25

quired style at the Position option and finally select [OK] then the first layed as a big letter.

3. Select the reletters of that paragraph will be disp

Note: To cancel the drop cap, select None option from Drop cap dialogue box. Changing case

1. Select the data to change it's case.

2. Select Format Change case bar, the dialogue box will be displayed as follows.

3. Select the required case and finally select [OK]

Working with Tables.

A table consists of number of rows and columns used to store data in the rows and the columns. The steps to insert the table are as follows.

1. Sele ert table from the menu bar, the dialogue box will be displayed (as ct Table Insshown in the next page)

Page 27: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

2. Enter required number of rows and columns and select [OK] then the required table

will be displayed.

Entering data in a Table.

Data can be entered in a table by placing the cursor in the required column of the table and start ent n eys to move the cursor in and around the eri g data. We can use either Tab or Arrow Ktable.

C ursor movements in a Table.

Key Movement Tab Next column in the RowShift + Tab Previous column in the Row Alt + End Last column in the Row. Alt + Home First column in the Row. Alt + Page Up First row in the Column Alt + Page Down Last row

Selecting a Row/Column

Pla t extreme right side of the row to select it, when ce the Cell pointer apointer changes to <-> t n click the mouse button to select the entire row. he

Place the Cell pointer at top of the column to select it, when pointer changes to

button to select the column. then click the mouse

Inserting a blank Row/Column

1. Select the entire row/column where you want to insert blank Row/Column. 2. Select Table Bar Blanks followed by Insert Rows/Columns from the Menu

columns will be displayed within the selected Rows/Columns.

Deleting entire Rows/Columns

1. Select the entire rows/columns to delete them. 2. Select Table followed by Delete Rows/ Columns 3. Selected Rows/Columns will be deleted.

OFILMK 26

Page 28: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK 27

OFILMK 27

Splitting a cell

A cell is the cross section of row and column. We can split a cell into number of rows and columns. The steps are as follows.

1. Place the cell pointer in the cell to split it. 2. Select Table Split cells from the Menu bar, the dialogue box will be

displayed as follows.

3. Enter the required number of rows & columns and finally click [OK]

Merging Cells

Two or more rectangle area of cells can be merged together to make a single cell. The steps are as follows.

1. Select the cells to be merged by means of dragging. 2. Select Table Merge cells from the menu Bar then the selected cells will be

merged as a single cell.

Table AutoFormat

Table also can be formatted with different style the steps are as follows.

1. Place the cursor any where in the table. 2. Select Table Table AutoFormat from the menu Bar, the dialogue box will

be displayed as follows. 3. Select the required format and finally click OK

Page 29: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

28

Sorting a Table

Sorting means arranging the data either in ascending or descending order of alphabets. For example if you enter all employees data in a table and you want to displays the table in alphabetical order of employee name, the steps are as follows.

1. Place the cursor any where in the table. 2. Select Table Sort from the Menu bar then the Sort dialogue box will be

displayed-as follows.

3. Click on Header row option if your table consists of Columns Names. 4. At Sort by option select the column name to sort by it and finally select [OK]

Note: In order to sort a table it should not contains any merged or splitted cells. Using

Formulae in Tables.

Some sorts of formulae can entered in a table to carry out a few mathematical operations. For ex h consists of employee data. ample we can find out the total Salary of employee in a table whicThe st mula in a table are as follows. eps to enter for

1. Place the cursor where you want to display the result of the formula. 2. Select Table >Formula from the Menu bar, then the dialogue box will be

displayed as follows. 3. Word automatically uses SUM (ABOVE) function at the Formula Box 4. If you want to find the total of the above cell in the column select OK then the

result will be displayed where the cursor is placed in table.

Splitting a Table

A Table can be splitted as two individual tables, the steps are as follows.

1. here you want to split table. Place the cursor in the row from was o tables. tw

Page 30: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Spelling & Grammar checking

Microsoft Word consists of American based English dictionary using which we can check the spelling the & Grammar of the entered data. Usually MS-Word will automatically checksspellings as you type the data. If any spelling mistake is there then the Word underlines the data with red col rammatical mistake is there it underlines our (This underline will be not be printed) and if any Gwith blu colour. Hence we can know the spelling and grammar mistakes while typing itself. e

The steps for spelling and Grammar checking are as follows.

1. Press the right button of the mouse on the wrongly spelled word then it display various corrected words.

2. Select the correct word just by clicking on it.

Or

1. Select Tools > Spelling and Grammar Menu Bar then the Word starts checking the spelling it stops at wrongly spelled word by displaying the following dialogue box.

2. Click Ignore to ignore and check the next word

OFILMK 29

Page 31: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Click Ignore All to ignore all the occurrence of particular and continue checking Or

Click Add to add the word in the Dictionary.

3. Click on the correct word from the given suggestions and click Change to change the current occurrence of the word.

Or

Click Change All to change the all occurrences of the word with the selected word from the suggestions.

4. Continue the above steps until the word finishes the spelling checking or Click Cancel to close the Spelling and Grammar dialogue box.

Macros in MS-WORD

A macro is a name that represents sequence of characters or operations so that by executing a macro we can substitute the same sequence of characters or we can do the same set of operations number of times.

If you perform a task repeatedly in Word, you can automate the task using a macro. A macro is a series of Word commands and instructions that you group together as a single command to accomplish a task automatically. Instead of manually performing a series of time-consuming, repetitive actions in Word, you can create and run a single macro - in effect, a custom command - that accomplishes the task for you.

Recording a Macro

To record a macro in Word, start the macro recorder and perform a sequence of actions. You can then run the macro whenever you need to perform this sequence. For example, if you often need to insert a specifically formatted table in your documents, you can record a macro that inserts the table with the correct borders, size, and number of rows and columns.

The steps to create macro are as follows.

1. Select Tools > Macros > Recording a New Macro Menu Bar, and then the following dialogue box will be displayed.

OFILMK

30

Page 32: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

31

2. At the Macro name option type the name of the macro (Short cut name). 3. At the Description option type the full description of the macro (This description will be displayed while running the macro). 4. Click the Keyboard icon to assign a short cut key to the macro and the dialogue box is as follows.

5. Enter a new short key at the Press new shortcut key option and click close.

6. After this the recording will be started you can now type any text or any sequence of operations.

7. Press (stop recording) button from the displayed tool bar to stop the recording.

Running a Macro

We can run or execute a macro just by pressing it's shortcut or using the following steps to run a macro.

1. Select Tools > Marcos > Macros from the menu bar(or press Alt + F8) then the Macros dialogue box will be displayed as follows.

2. Select the required macro and click Run] to run the macro.

Page 33: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK 32

Deleting a Macro

1. Press Alt + F8 to get Macros Dialogue Box.

2. Select the required Macro to delete it and Click Delete then the Word will ask for confirmation Click Yes to delete it.

Note: We can also a modify a macro in Visual Basic Editor. Mail

Merge

Mail merge is the process of sending the same information to different add e all of your friends and relatives for your resses(sources). For example if you want to invitbirthday party, the body of the letter person to is same only the address will be changed from one ano r mail the . You can store all the addresses in a file and body of the letter in another file. By using merge w he required number of letters. e can create t

Mail merge consists of the following files.

1. body of the letter. Main Document: It is a document file that consists of

2. Dat t consists of number of addresses. Data a Source: It is also a document file thaSource can be created by following the following rules.

A. All the addresses should be n a table. entered i

B. The first row of the table sh e c e or h o the ould contain th olumns nam eading tcolumns data.

C. Duplicate field names are not allowed.

D. Each address should entered in a single row only.

A typical data source file is as follows.

Name Qtr no Place City PIN Moshi N 1-52/F Vemuru Guntur 522 261 Amal Kumar Nath 3593 Yeddumailaram Hyderabad '502 205 Chandra Mohan J 3777 Yeddumailaram Hyderabad 502 205 Rajendra Prasad 22250 Yeddumailaram Hyderabad 502 205

Process of Mail Merge.

1. Create the Data Source by entering all addresses in a table & save them in a file (say ADDRESSES)

2. Open a New file and entering the Body of the Letter and save it (say INVITATION). This is the Main Document File.

Page 34: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

33

3. From the Menu Document file Select Tools > Mail Merge from the Menu bar, and then it's dialogue box will be displayed as shown below.

4. At the Main Document option click Create and select Form Letter then the dialogue box will be displayed as follows.

5. Click Active Window after that it returned back to previous window.

6. Click on Data Source and Select Open Data Source option.

7. Open the data sources file (ADDRESSES) after that it displays one more dialogue box as follows.

Page 35: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

34

8. Click Edit Main Document to insert merge fields into your main document then Mail Merge Toll bar will be opened in the Main Document.

9. Place the cursor where you want to insert your address fields.

10. Click Insert merge field icon from the Mail Merge tool bar and select the required fields to be appeared in the addresses.

11. After inserting to 'New Document icon from the Mail Merge toll bar and then all the letters will be generated & stored in a new file. You can save this file for further use.

A typical Main Document with merge fields is as follows.

I beg for your precious blessings on the occasion of my birth day party to be celebrated

as per the given seclude.

Date : 7th May , at 1900 Hrs.

Venue : Of Estate, Yeddumailaram, Medak Dist. A.P

You & your family member's gracious presence only can make the function a grand success.

Yours lovingly.

(XXXX)

Page 36: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

4. MICROSOFT EXCEL

hat is

an also integrate documents and information created

am and then paste it into your Excel worksheet. Or, you may cument into another using your mouse. Finally, you may simply

port one kind of document into another. This flexibility gives you the ability to work in ways that best uit your personal tastes.

he Worksheet A worksheet, sometimes called a spreadsheet, is nothing more than a large planning form made

p of columns and rows. Excel uses a workbook-style presentation which is made up of several orksheets, like pages in a note ook. Look at the following illustration.

W Excel? Excel is a full-featured spreadsheet program that is used by millions of people around the world. Excel 97 makes use of all of the features available to programs designed specifically to run with a 32-bit operating system such as Windows 95 and NT 4.0. This means your version of Excel runs faster and more reliably than the older 16-bit technology programs. When acquired as part of Office 97, Excel uses a number of shared Office resources. This includes fonts, ClipArt, spelling resources, AutoCorrect, AutoText, and more. As with the other Office programs, Excel cby other Office and Windows programs. For example, you can insert Word document and Access tables directly into your Excel documents. In fact, you can put up to 32,000 bytes (or characters) in an Excel 97 cell. The ease and flexibility of doing this is impressive. For example, you can cut a portion of a document created by another progrprefer to "drag and drop" part of one doims T uwb Menu Bar

Column headings Ac tive Cell

Reference Area

Vertical Scroll Bar

OFILMK

35

Row Numbers

Worksheet tabs Horizontal Scroll Bar

Status bar

Page 37: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

36

The above screen shows the Excel toolbars, which are a series of short cut icons that are used in place

Excel lets you display several different toolbars using the Toolbars selection on the View menu.

A cell is the intersection of a row and column. The following few paragraphs describe rows,

ows and Columns: Notice that the rows are numbered from top to bottom along the left edge of the re are 65,536 rows. The columns

re labeled from left to right with letters. The first column is A, the second is B, and so on until you is

e 256th column.

specify the first and last ell in a row, column, or rectangular area. Here are two examples of ranges. .

3:E12-All cells in column E from row 3 and to and including row 12.

command by moving to it with the Up or Down Arrow key and pressing Enter, by typing one of the underscored letters, or picking the selection with the mouse. If you change your mind, press Esc to cancel your last selection. Here you see the Tools menu; the Options menu selection is highlighted. The ellipses (three dots) tell you that this menu selection displays a dialog box. In this case, the Options dialog box is displayed. Notice the filled triangles to the right of the Track Changes, Auditing, Protection, Macro, and Wizard selections. This symbol indicates the use of a simple pick list from which only one selection can be made.

of the series of keystrokes or mouse clicks used to access commonly used worksheet features. For now, concentrate on learning the worksheet basics. Once these are learned, you will able to create worksheets for a wide variety of purposes. Rows, Columns, and Cells columns, and cells, which are the basic elements of worksheet. Rworksheet. The first row is numbered 1, the second 2, and so on. Theareach Z. Then come to columns AA through IV. The last (or right. most) column of the worksheet, IV,th Two or more adjacent cells are referred to as a range of cells. Rangesc E C3:G20--All cells in the rectangular area bounded by C3 at the upper left and G20 at the lower right. Cell ranges are handy. For example, you can add or average a group of values in a column, row, or rectangular area. You can also format, copy, move, or delete a range of cells. Menus and Dialog Boxes Look at the menu bar across the top of the worksheet illustration. Each menu is accessed by either clicking on it with the mouse pointer or by pressing the Alt key and then typing the underscored letter. This pulls down the corresponding menu. For example, to display the selections that correspond to the File menu, pick File on the menu bar or press Alt and then F, represented by Alt, F. Now you can activate a

Page 38: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Dialog Tabs The preceding dialog example has several "pages" that are accessed by clicking one of the folder-like tabs. Many dialogs have a single box, while others display a Next button to provide access to additional selections, as is the case with most Wizard dialogs. Within each dialog box you work with a variety of setup tools including text boxes, pick lists, check boxes, option buttons, and selection buttons. Once you establish the desired setup, click OK or press Enter for your changes to take effect; to cancel changes, click the Close or Cancel button or press Esc.

Shortcut Keys Many menu selections are accessible through shortcut keys. For example, Alt+F4 gives you direct access to Exit (quitting the program) without having to first pull down the File menu. Pressing and holding the Control key while pressing S, represented by Ctrl + S, saves the current worksheet. Sheets

Excel is organized like a workbook with multiple pages labeled Sheet1 through Sheet n, where n is a number. You can change sheet (or worksheet) names to suit your needs, and sheets are easily copied and moved. Initially 3 worksheets are available. Additional worksheets can be added as necessary. (Use the General page of the Tools Options dialog box to set the number of sheets in a new workbook.) Notice that Sheet1 through Sheet3 displayed on the Excel screen illustration. Use the scroll buttons at the bottom left-hand edge of your screen to access more sheets.

Each worksheet is independent of the others, although the values in differ sheets can be combined, letting you work in three dimensions (across, down and vertically). Many users take advantage of this feature to consolidate values from multiple sheets. For example, you might consider separating financial information by month, year, or checkbook register with each period's values on a different worksheet within the same workbook. You can access the contents of different sheets by pressing Ctrl + PgDn or Ctrl + PgUp or by clicking on the desired worksheet tab with your mouse. Moving Around

OFILMK

37

You can use your cursor keys or a mouse to move to any cell on the worksheet. You can also press F5, the GoTo function key, type a cell coordinate (such as C2l), and press Enter to move directly to a desired cell. Use the following keys to move the screen a page at a time.

Page 39: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

38

PgUp, PgDn - Move one page up, one page down Ctrl + Right/Left Arrow - Jump to right/leftmost cell Ctrl + Up/Down Arrow - Jump to top/bottommost cell Home - Jump to beginning of row End + Right Arrow - Jump to end of row Ctrl + Home - Jump to cell A 1 (upper left corner) Ctrl + PgUp - Move to the previous workbook sheet Ctrl + PgDn - Move to the next workbook sheet F5 - Go to a designated cell Entering Information When you point to (or highlight) one or more cells, you can type text, numbers, a formula, or perform a menu operation. Text

You can type a descriptive column or row heading, which is considered a text entry. You can also type notes, dashes, or symbols. You can center or position text flush left or flush right by highlighting the cell and picking the corresponding icon on the toolbar located just under the Macro and Window selections of the menu bar. Numbers

Numbers are typed directly. For example, you can type 12.1457, -11.5, or 5. You can also type =12* 10.5 to display the product of 12 and 10.5. This is a simple formula. Numbers can be formatted using the Format Cells menu selection (Alt + O, E or simply Ctrl+1). You can select a fixed number of decimal places, percent, currency, and a variety of other notations. The Formatting toolbar is also useful for formatting; just select the cells and then click the desired format style button for currency, percent, comma style, or to increase or decrease the number of decimal places. If a column width is too narrow or too wide, use the Format Column Width menu selection (Alt + O, C, W). Here, you can adjust the width of one or more selected columns by entering the width in inches or pick AutoFit to let Excel make the adjustment for you (Alt + O, C, A). You can also put the mouse pointer on the column letter row and drag the column intersection to the right or left. Formulae

Formulae establish relationships between two or more cells. If you want to add the values in cells E7 and E8 and put the result in cell E9, move to cell E9 and type =E7+E8 and press Enter. The result is displayed immediately in cell E9. Another way to achieve the same result is to move to cell E9, +, point to E7, type +, then point to E8, and press Enter. The easiest way to achieve this operation is to point to E9, pick the AutoSum button on the Standard toolbar, and press Enter. This pointing technique eliminates the need to look up cell coordinates and avoids potential typos, which could result in an erroneous addition operation. You can also refer to values on other worksheets of the current workbook using the sheet designator or name. For example, if you want to add the values in cells B5 of Sheet1 and Sheet2 and place the result in Sheet1 B6, place the cell pointer in Sheet1 B6, type the formula =B5+'Sheet2'!B5, and press Enter. Note that you can also type =, click on cell B5, type +, click on Sheet2 B5, and press Enter. Excel automatically inserts the designated, addresses in your formula. As you type each operator, such as =, +, (, etc., Excel expects you to pick or type a cell or range reference.

Page 40: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

The program also has a number of mathematical functions for findings such things as the sum, average, minimum, or maximum value within a specified range of cells. For example, the formula =SUM (C5, CI5) yields the sum all values in the range of cells C5 through C15. Notice that worksheet functions start with the = sign. Excel converts @ entries to = automatically, which helps those users who are familiar with other worksheet programs use the @ symbol to designate functions. A comprehensive list of workbook functions by category is listed in the Insert Function dialog box. Information about functions is also found in Excel's extensive on-line help. A few user functions are: =SUM - The sum of values within a range of cells =AVERAGE - The average of values within a range of cells =MAX - The maximum value within a range of cells =MIN - The minimum value within a range of cells Relative and Absolute Referencing It is important to have a clear understanding of the difference between relative and absolute cell referencing. Most formulas include cell referencing. Unless you tell the program that a cell reference is absolute, it is assumed to be relative. A relative cell reference is established by beginning a formula entry and then pointing to one or more cells (or typing the cell coordinates) where involved values are stored. The location (or locations) of the involved values is relative to the location of the formula, where the result is placed. For example, assume that you type a formula in cell C17 that uses a referenced range of cells in columns C3 through C15. If you copy the formula from C17 to C17, the range referenced by D17 automatically uses the range of cells D3 through D15 - still a range of 12 cells directly above the formula. Hence, the reference is adjusted relative to the new location of the formula. Copying or moving a formula to a different location simply adjusts the cells used relative to the new location of the formula. This feature permits you to insert new rows and columns, copy ranges (or blocks) of cells, and so on, without changing the validity of your formulas.

An absolute reference always points to the same cell coordinate. Absolute referencing is ideal for some

ixed markup, or monetary exchange rate. This lets you create a constant value such as a tax rate, f

OFILMK

39

Page 41: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

fo

OFILMK

40

rmula and copy it to several other cells without changing the absolute reference to the cell where the con n ows how relative and absolute values are used in a ser o The pr lumn B by 27.5% (1.275 x B2 through B6). The form reference D9, which

sign in front of a row and/or column coordinate tells the worksheet to eat it as an absolute reference. Copying or moving a relative reference from one cell to another

ative reference automatically. In the example, coordinate B2 is automatically converted solute cell reference leaves the

next math operator, such as +, omplished by pointing to a cell serts a $ sign in front of the row

o maintain the reference to the

eet, tab, labeled Sheet1, is active and ready for your entries.

s <AIt+F4> or use <AIt, F, X> to exit the worksheet program, returning to the Windows desktop.

r of the orksheet. You can also use <Alt, H> (or pick Help on the menu bar

o pick a selection (or

ress <Shift+F1) to access context-sensitive help. Just point to an es the a menu item is highlighted, such as the r), you can press F1 to display helpful e process, the Help feature senses the

current activity.

ool bars

xcel displays one or more toolbars containing a row of related buttons across the top of your screen. rs are displayed; the Formula bar, which h button on a toolbar offers a shortcut rations. For example, clicking the Open

sta t value is stored. The following illustration shies f formulae.

eceding example marks up the costs in coulas in column C use relative coordinates B2 through B6 and the absolute cell

contains the value 1.275. The $ trconverts its relto B3 through B6 when copied down. However, copying or moving an abreference to cell D9 intact. A relative cell reference is designated by pointing to a cell and pressingor pressing Enter to finish formula entry. Absolute cell reference is accand pressing which designates the cell as absolute. The F4 key press inand column coordinates, such as $D$9. The $ signs tells program tvalue in D9 regardless of where formula is copied or moved. Starting and Exiting the Program

1. Start Microsoft Windows Operating System. 2. From the Programs group list or the Microsoft Office toolbar, click Microsoft Excel. 3. Notice that a blank workbook named Book1 is displayed; the first worksh

4. Pres Getting help To display help information using the Office Assistant, click the Help button on the Standard toolbar or press F1 in the Ready mode, i.e., when "Ready" is displayed at the bottom left hand comewwith your mouse). If you use the Help menu, select Contents and Index to display a Help Topics dialog. Use the index tab to access information by typing a word or phrase. Use the Contents tab tsubject from a list of help topics. Use the What's Thispobject and Excel's context sensitive Help feature describselected item. Press <AIt+F4> to close the Help dialog. WhenClear selection on the Edit menu (referred to as Edit Cleainformation about the current process. When involved in somfeature in use and displays information that corresponds to the T EWhen you first start Excel, the Standard and Formatting toolbais used to enter and edit cell values, is also displayed. Eacmethod of performing commonly used file and workbook ope(file folder) button performs the File Open menu operation.

Page 42: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

You can open and close toolbars using the View Toolbars menu selection Display of the Formula Bar (where a formula, text, or value within a selected cell is displayed) is controlled by clicking the View Formula Bar menu selection. se the Toolbars list by

y or hide toolbars.

stomize dialog. Here, you rs and even create new toolbars of r tab to select the toolbar you want

b to drag button to the

.

a process and return to opened a window, you may have to

This lets you display

you make an ection in the Edit menu.

or example, if you accidentally delete something, use to restore it. Excel maintains

p to 16 undo levels.

etting Up (Tools/Options)

he Tools Options menu selection displays a dialog box that controls the way Excel looks and orks. There are ten different Options dialog boxes that are accessed by clicking the tabs. Each dialog ox displays a different group of setup choices. The more frequently used Options dialog boxes are riefly described here. You can examine Excel's built-in Help information about any dialog box by isplaying it and then pressing F1.

Uclicking on the check boxes to displa Use Customize to display the Cucan modify exiting toolbayour own. Use the Toolbato modify. Use the Commands tadesired toolbar. The Customize feature gives you a way toadd shortcuts to frequently used items. The Cancel and Undo Keys The Esc key is used to back out ofthe worksheet. If you've use Ctrl+F4 or Alt+ F4 to close it.menus and submenus and then gracefully back out of them without having to use unwanted features. If error, Excel provides an Undo selFEdit Undo (or press Ctrl+Z)u

S Twbbd

OFILMK

41

Page 43: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

V

OFILMK

42

iew-Use the check boxes to control what is displayed and hidden. This dialog box is critical to both isplayed and printed information.

dit: - Use the check boxes to control the way information is entered into cells and transferred between them.

rkbook sheets, the t and size, the default file path for workbooks, and the user menu

d E

eneral: Use to set cell references style(A1-R1C1), menu style, number of woGstandard fon

Color: Set the standard colors to use for your workbooks and charts.

Page 44: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Calculations: Change the way Excel performs the calculations

Transitions: Set the format of saved files, Excel menu and help keys, and the way formulae from imported files are evaluated.

OFILMK

43

Custom Lists- Use these lists when using Edit Fill Series AutoFilI. You can add your own custom lists for use with AutoFill. Just type the first element in the series, highlight the target row or column,

nd click the Series dialog's OK button. a

Page 45: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Chart : Use this dialogue to set the way values within a chart are plotted. Also establishes what is displayed or ignored such as zero values.

T

OFILMK

44

he File Menu

selection on the File menu. Each selection is briefly the following list.

You may wish to review the purpose of eachsummarized in

Page 46: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

45

New- Open a new blank workbook, chart, or macro sheet. Excel provides a New button (the page

ad multiple workbooks in different windows.

r a backup file can be produced. You can also specify different save formats. Excel provides

window, including ooters, sizing, centering, and more.

to print the current selection.

Microsoft Exchange, as regular e-mail, or to a

tive file such as the title, author,

pening Workbooks

blank workbook, entitled Book1, is automatically opened and ready for you to begin workbook reation when you first start Excel. If you wish to retrieve an existing workbook, you can click the Open

ile Open command <Alt, F, O> to display an Open dialog box. Here, a lot of files l workbooks have the file extension .XLS. Pick the file of our choice and click Open.

To open the TRAVBK workbook, perform the following steps.

button) on the Standard toolbar. Open - Open a new workbook. This selection lets you loYou can use your mouse or the Window menu to move between open workbooks. You can also load files created by other programs, such as dBASE and Lotus 1-2-3. Excel analyzes foreign files and converts them as they are loaded. Excel also provides an Open button (the file folder) on the Standard tool bar. Close-Close the current (or active) workbook. Save - Save the current workbook. Unnamed workbooks are named. Existing workbooks are either eplaced or

a Save button (the diskette button) on the Standard tool bar. Save As- Save the current worksheet under a new filename, or export a file in another file format such as a Lotus 1-2-3 or Multiplan worksheet or an Access or dBASE database file. Save Workspace- Save all currently active and open documents, window layouts, chart settings, etc. When a workspace is loaded at a later time, the previously saved environment, including all documents,charts, etc., are opened. Page Setup- Set the appearance of a printed workbook, macro sheet, chart, or info uch items as margins, headers and fs

Print Area- Define the selected range of cells as the area to print; non-selected cells are omitted from what is printed. This selection is also used to clear (reset) a selected print area. Print Preview- Display a graphic representation of the printed workbook. Print- Print the open workbook to the selected Windows printer, or preview the worksheet on screen. (Excel includes Page Setup dialog with this selection.) You may also use the Print button on the standard toolbar

Send To- Send the workbook to other people usingrecipient whose address is stored in Microsoft Outlook.

n about the acProperties- Display Properties dialog showing informatiocontent information, dates, size, etc. O

Acbutton or use the Fare displayed. ExceThe file is opened and ready to use. Once a workbook file is open, you can enter values, edit it, display charts, print or create and edit macros. Tip: Notice that the last four filenames used are displayed at the bottom of the File menu. You can pick one of these names or type the corresponding number, 1 through 4, to open the file. You can use Tools Options to change the number of files displayed at the bottom of the File menu.

Page 47: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

46

1. Start Excel. 2. Load the TRAVBK workbook: Click the Open button, pick TRAVBK <Enter>. 3. Notice that the TRAVBK workbook is displayed, ready for use. 4. Quit the program: <Alt+F4> (or use the File Exit menu selection). Opening Files from Other Directories and Disk Drives

Files are selected from the dialog box that is displayed when you click the Open button, press <Ctrl+O>, or use the File Open menu selection. You can double-click the desired filename or select it and click Open. If you want load workbook from another disk drive, such as drive A, or from another file folder, just type the drive designator, file path, and the filename in the File name box. For example, typing A:\ WKS\TRAVEL loads the named workbook from the WKS path on the diskette in drive A. Once typed, press Enter or click Open. You can also pick a drive and pathname from the Open dialog. Just click the Look in box's down triangle to display a list of drives and pathnames from which to choose.

he Open dialog box includes a Files of type pick list from which you can import a variety of file types oft n

n. This utton gives you instant access to file folders that you select for saving and retrieving files.

l "remembers" your selection and uses it until you ither exit the program or change to another drive and/or file path.

pening Two or More Workbooks

ou can open more than one workbook at a time. Each workbook remains in its own window and is

can use the mouse to adjust window sizes so that they overlap. This chnique lets you pick the desired window with your mouse. Finally, you can use Window Arrange to

Tcreated by other programs. For example, you can import an Excel workbook produced by MicrosExcel 4.0 or 5.0, Quattro, or even dBASE database format. You may wish to experiment with the Opedialog buttons to determine their purpose. Of particular interest is the Look in Favorites buttobIf you pick a different disk drive and/or file path, Excee O Yaccessed using the Window menu. Use <Alt, W, 1> to display the first workbook, <Alt, W, 2> to display the second, and so on. YouteTile or Cascade workbook windows on the screen. Experiment with two open workbooks using the following steps.

Excel. Notice that a blank Book is displayed. 1. Start

. Ope

. Display Travbk1 (the first window) again: <AIt, W, 2>.

2. Open the Travbk1 workbook: <Alt, F, 0> pick Travbk1 click Open. n the Sesales1 workbook: <Alt, F, 0> pick Sesales1 click Open. 3

4

Page 48: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

5. Display both worksheets: <Alt, W, A> choose Tiled <Enter>.

pen Dialog Box

trl+O> displays the Open dialog box. This dialog is sed to find, open, delete, and copy files in addition to accessing the Internet. As you pick workbook

ties, Preview, and ustration, the Commands and Settings button and

e corresponding menu selections are shown. You can click each button to determine its effect.

O The File Open menu selection, Open button, or <Cunames, you can display information about each file using the List, Details, ProperCommands and Settings buttons. In the following illthFollowing is the brief description of each;

Note: The Open dialog provides numerous search aids. For example, you can find files that match criteria that you supply. Use the Advanced button to display another dialog that finds files that contain specified information. You can also save commonly used searches for later use.

evel-Use to move up one file folder level.

U

p One L

Search the Web-Use to access the Internet by launching Microsoft Internet Explorer. Look in Favorites- Use to access those folders stored as "favorites," Add to Favorites- Use to add the currently selected folder as a "favorite, which is then accessed using the Look in Favorites button. List- Use to find files in different directories and/or on different disks, Also use to specify the file types to list by supplying different file extensions or wild cards. This selection also lets you name and save your save setups for future use. Preview - Use to display a thumbnail sketch of the selected workbook file. Details - Display detailed information for each file listed.

OFILMK

47

Page 49: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

48

Properties - Display summary information about the selected file including such things as author name, saved by, date created, date modified, company, etc.

tings- Use this button to perform one of the following file operations:

Open Read Only-Open file; "read-only" prevents changes.

Open As Copy-Open a copy of the selected file, leaving the original intact.

Properties- Display detailed information about the selected workbook file.

Sorting- Choose to display files by name, size, file type, or the date last modified in either

Search Sub/Folders- Click this selection to display a complete directory structure (or "tree") and corresponding workbook files. When checked, the Group files by folder become active.

Group Files by Folder- Permits you to select and display filenames from different folders as one list.

Map Network Drive- Connects you to the selected (or "mapped") drive of a networked computer.

Add/Modify FTP Location- Displays the Add/Modify FTP Locations dialog that is used to identify File Transfer Protocol folder and address at an Internet service provider's web site.

Saved Searches- Used to recall search criteria that were previously used and saved. Each search criterion is established and saved using the advanced button and the corresponding Advanced Find dialog.

here are two general ways to save workbook files: File Save and File Save As. You can also click

ave

You can save the current workbook .using <Alt, F, S> (for File Save) or by clicking the Save button. The current workbook is saved to disk. If the workbook is a new one and has not been saved previously, you are prompted for a filename. If the current workbook already exists, it simply write the previous version. If you wish to keep both the old version and new version of the current workbook, use File Save As. Save as This file option, accessed with <AIt, F, A>, saves the current workbook1 a new filename, creates a backup file, or saves the file in a different format.

Commands and Set

Print- Print one or more selected files; this choice displays the Print dialog box.

ascending or descending order. Saving Workbooks Tthe Save button on the Standard toolbar or press <Ctrl+S>, which are both shortcuts for File Save. S

Page 50: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

The simplest Save As operation lets you type a new filename and click Save. Use the "Save as type" selection to save a file in a different file format. There are 29 file formats to choose from, depending on what was selected during setup. These formats include spreadsheet, text, and database formats. An ideal use for Save As is when you load a standard workbook, enter and then save it with a new descriptive name. For example, you can load Travbk workbook, enter expense data that corresponds to a specific trip, and then save as Travel 11-97, which might indicate travel for November 1991. You can also use File Save As to export workbooks for use in other programs including word processors, database programs, and other spreadsheet programs such as Lotus 1-2-3 or Multiplan. You can save the workbook as CSV text file if you want to use it as a word processor mail merge file. For example, most word processing programs, such as Microsoft Word and Corel WordPerfect, make use of comma-delimited data files. The Format Menu

OFILMK

49

The Format menu and its dialogue guide you through a variety of format choices. Notice that some selections are followed by a filled triangle, indicating a submenu. The choices followed by the ellipsis ( . . . ) display dialog boxes. The dialog boxes associated with Cells, AutoFormat, and Style are described and illustrated below. Format cells Notice how six different format selection sets are included with the Format Cells dialog. You can display a dialog set by clicking the corresponding notebook-style tab.

Page 51: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

umber-This dialog box is shown in the preceding illustration. It is used to set the format of numbers, ates, or text within the currently selected cells. A sample box displays an example of the selected rmat.

lignment- Use to set the horizontal and vertical alignment of selected values. The Wrap Text check ox is used to wrap text within the current cell(s).

Ndfo Ab

Font: Use to select a font name, style, size, color and special effect

OFILMK

50

Page 52: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

51

Border – Use to put boxes and rules around one or more selected cells.

Patterns : se to put a color or pattern within one or more selected cells.

U

Page 53: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Protection - Use to protect or hide formulas within selected cells. Protection has no effect unless you follow up by using Tools/Protection to protect a worksheet.

Format Row-Use to adjust the height and to hide or unhide selected rows

e of the preset formats.

Format Column- Use to adjust the width and to hide or unhide selected columns. Format Sheet-Use to rename, hide, or unhide the selected worksheet. Format AutoFormat-Use to change the look of your data by picking on

Format Style- Use to set up format settings to selected styles. Preset styles are easily applied to the alues in one or more selected cells. v

OFILMK

52

Page 54: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Placement - Use with graphic objects, such as lines and boxes. The Bring to Front and Send to Back

selections put graphics on top of or behind other objects, such as values or other graphic elements. The Group selection combines two or more graphic elements together. Pick multiple elements with the mouse pointer by holding down the Shift key.

Formatting Toolbar The Formatting toolbar is normally displayed when you start Excel. If it isn't, use View Toolbars, click the Formatting check box, and click OK. Each of the buttons on the Formatting toolbar is illustrated and described for you. To use the formatting buttons, select the desired cells and click the appropriate formatting buttons.

OFILMK

53

Set the font by picking a font name from the pick list. ont size of the text or numbers within the selected cells.

Fill selected cells with a color or pattern. 0 Apply color or pattern to selected text.

3 4 5 6 7 8 9 10 1 2 12 Set the f3 Set text or numbers within selected cells as follows: B=Boldface, I=Italic, U =Underline. 4 Align selected cells left, center, or right. 5 Center text in one or more selected columns. 6 Format value as currency, percent, comma style, or increase/decrease decimal places. 7 Increase/Decrease Indent of text within selected cells. 8 Apply borders or rules to selected cells. 91

Page 55: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

5. MICROSOFT POWERPOINT

What is PowerPoint?

owerPoint is a full-featured presentation program that is used by millions of people around the world. d to design presentations for a variety of presentation mediums including computer-

s. Overhead projection transparencies and 35-mm slides. You can also add sound

resentations in PowerPoint 4.0 (l6-bit) format, so those people who 3.x can run your presentations.

eatures available to programs indows 95 and NT. When

. PowerPoint uses a number of shared Office resources. This includes fonts.

s and information created by ows programs. For example, you can insert Excel spreadsheet or Word table

export a slide presentation to a Word document with the toolbar. The ease and flexibility of performing these

PPowerPoint is use

ased display showband animation to your slides to achieve a high level of impact. PowerPoint also gives you the ability to prepare paper-based presentations and handouts for your audience. You can also package and distribute your presentations with a PowerPoint Viewer. You can

ven package and distribute your peare still using Windows As with the other Office 97 programs PowerPoint makes use of all of the f

run with a 32-bit operating system such as Wdesigned specifically to cquired as part of Officea

ClipArt, spelling resources, AutoCorrect, Internet Explorer, and more.

7 programs. PowerPoint can integrate documentLike all other Office 9ther Office and Windo

directly into a PowerPoint slide. You can alsolick of a button on PowerPoint's Standardc

operations is impressive. PowerPoint Views The View Buttons The following figure each of the view buttons.

Slide View The Slide View is used to create and edit your slides. This is the default view when you first open

utline View

e format of your slide show. The slide number and text ontents are displayed in this view. In this view you can edit the displayed text, delete slides, and even

PowerPoint. In this view, all of the menus and tool bars are available for use. Use this view to insert and edit the contents of your slides. O The Outline View is used to display an outlinc

OFILMK

54

Page 56: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

cut and paste slides from one location to another. Cutting and pasting is possible within the same presentation or between different presentations.

Slide Sorter View The Slide Sorter View gives you a miniature picture of each slide. You can use this view to sedrag slides from one position to another within

lect and your slide show. In this view you can even display two

o the other. sets of slides simultaneously and then drag and drop slides from one presentation t

Notes View The Notes View is used to enter notes (or a script) for the slides within a presentation. Once the notes

re added, you can print the slide show and use the printed ouao

tput as a script. You can also give copies f the printed material to your audience as in-depth handouts.

OFILMK

55

Page 57: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

lide Show

ll screen. It is used to either actually show or simply review your slide resentations. Use this view to check final sizes, colors, animation, transitions between slides, sounds,

and other controls. To check the timing of a self-running presentation, use the View Slide Show menu selection. You can also distribute your presentations with the PowerPoint Viewer program, used to run presentations without the actual PowerPoint program.

e Show

ll screen. It is used to either actually show or simply review your slide resentations. Use this view to check final sizes, colors, animation, transitions between slides, sounds,

and other controls. To check the timing of a self-running presentation, use the View Slide Show menu selection. You can also distribute your presentations with the PowerPoint Viewer program, used to run presentations without the actual PowerPoint program.

S This view displays the slides fu This view displays the slides fupp

ile Page Setup

r Office applications. Use it to adjust the size and orientation of your displayed slides, as well as the beginning

age number. You can adjust the size of your slides for use as an on-screen show (default), a 35-mm t you set

ustom sizes as well. You can also change the orientation of both slides and paper-based handouts

F This dialog is displayed using the File Page Setup menu selection, which is similar to othe

pslide show, a paper-based letter- or A4- size presentation, etc. The Height and Width boxes lecfrom landscape (horizontal) to portrait (vertical).

OFILMK

56

Page 58: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

57

File Properties

se this menu selection to display general information and detailed statistics about the current slide set of information.

The best way to determine the kind of information provided is to open and browse the Properties dialog hen a slide presentation is open.

ile Menu Overview

n the Standard toolbar.

locate and select the desired file. You can also click the Open button on the Standard toolbar. Close- Close the current slide presentation. Save:- Save the active slide presentation. Save As- Save the active slide presentation with a new name, in a different file path or disk drive, or in a different file format (such as Windows metafile or PowerPoint 95, 4.0 or 3.0 format). Save as HTML- Save the current document in hypertext markup language format (compatible with web browsers). Pack and Go- Prepare one or more presentations for distribution. A Pack and Go wizard guides you

rough the preparation process. All necessary presentation and Viewer files are copied to designated

e) of the current slide presentation or handouts. Slides can be sized for on-screen, letter or A4 paper, 35-mm, overhead

jection, or custom use. Slide numbering is also controlled by this dialog.

Print- Print the current slide presentation. Printing option per page, as well as printing notes and handouts.

Upresentation. Five different tabs are available to this dialog. Each displays a different

w F New- Starts a new slide presentation. You can also click the New button o Open- Opens an existing slide presentation. Use the Open dialog to

thdestination disks.

age Setup- Display or change the size and orientation (portrait or landscapP

p

ro

s include printing from one to six slides

Page 59: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Send To-Send the current presentation as e-mail, as a fax through Microsoft Exchange, or to Word. se the corresponding dialog to make your selections. (Ideal for computers with a fax/modem or etworking card.)

roperties-Display a Properties dialog showing information about the current slide presentation.

xit-Exit the PowerPoint program.

ontrolling Text and Lists

Too/bar

ach of the buttons on the Formatting toolbar.

Un P E C Before using PowerPoint's text and list controls, review the following list and supporting illustrations for a good understanding of what you can do with the text and list elements of your slides. Formatting The Formatting toolbar, like that of other Office 97 applications, controls many facets of your text elements. The following illustration labels e

The following buttons are used to change selected text. Select text by dragging it with a mouse or clicking on the text and pressing <Ctrl+A>. Then click one of the following buttons to change the selected text as described. Font- Pick a font name from the list of choices.

d text bold or normal.

Left Alignment Align selected text left (the default setting). Center Alignment Center the selected text. Right Alignment Align selected text right.

Font Size-Pick a size in points (there are 72 points per inch). Bold-Set selecte Italic Set selected text italic or normal. Underline Set selected text underline or normal. Shadow Set selected text shadow or normal.

OFILMK

58

Page 60: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

59

Bullet (On/Off) Add or remove bullets to the selected paragraphs. Increase Paragraph Spacing Increase the space between paragraphs. Decrease Paragraph Spacing Decrease the space between paragraphs. Increase Font Size Increase the size of the selected text. Decrease Font Size Decrease the size of the selected text. Promote (Indent Less) Decrease the indentation level of the selected text. Demote (Indent More) Increase the indentation level of the selected text.

nimation Effects Display the Animation dialog to add special effects to slide transitions, text, and

o used to control the appearance of your text.

Aobjects. Format Menu

he Format menu is alsTEach of the Format menu selections are described in the following list. Font- Select a font, font size, style, color, effect (bold, underline, etc.), etc. from the displayed dialog.

Bullet- Select a font and corresponding bullet symbol of your choice from the displayed dialog.

Page 61: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Alignment- Select left, center, right, o displayed list to align selected objects. Line Spacing- Set the line spacing an

s.

r justify from the

d spacing before and after paragraphs. selected text to one of five different setting

hange case – ChC ange the case of the selected text to of the five different settings.

OFILMK

60

Slide Layout- Select one of the 24 slide layout templates from the Slide Layout dialog.

Page 62: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Slide Color Scheme- Pick a color scheme for the current slide using the Color Scheme dialog.

Background- Apply a background

ialog displays a preview. It also let fill color to either the current or all slides in the presentation. This s you choose different colors and gradients. d

Ae

pply Design- Select a design for your presentation using the following dialog. Notice that a preview of

ach is displayed to help you decide upon a suitable design.

OFILMK

61

Page 63: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Colors and Lines- Adjust the text object fill color, shading, pattern, and/or texture (textures include wood grain, marble, and fabric weaves)

OFILMK

62

. Shading, patterns, and textures add pizzaz to your slides. You the color and line style using

AutoShape- Use the displayed dialog to apply colors and line styles to the selected shape; available tabs vary with the type of object selected.

Tip: The Text and Picture tabs are sed with text

her object. You can use the Text tab to resize the object to fit interior text.

ar's Font Color button. Clicking the More Font dditional colors. A palette of standard colors is

ustom dialog where you can vary standard colors to suit your personal taste.

can also add a border to the frame that surrounds your text and control this dialog.

uwithin a frame or ot Color Control In the previous section you learned how to control the color of text and text object fills and borders. You used the Formatting and Drawing toolbars and the Format menu. The Format menu is also used to color the background of your slides. Recall that the color of text is quickly changed by selecting (highlighting) the text and then clicking the Drawing tool b

olors button on the Font Color palette accesses many aCavailable, as is a c

Page 64: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

These two palettes are also available for background coloring. The Format menu selections associated or control were listed in the last section. These are the Slide Layout, Slide Color

cheme, and Background selections. Recall that the Slide Layout dialog provides 24 different layouts from Slid e a custom color scheme of your

wn. The custom dialog was shown in the last section. Click the Custom tab to display the Custom

desired color and then click the OK button.

with background colS

which to choose.

e Color Scheme-

Use this dialog to choose a standard color scheme or to creatodialog shown below. Here, you can change the colors of any of the items in the Scheme colors list by clicking an item and then change the color by clicking the Change Color button and making a new color selection. The Standard and Custom color dialogs are used to change your colors. The Standard dialog offers a variety of fixed colors. Just click on the

The Custom dialog lets

lue of a color. Simply you adjust the hue, saturation, lumination, and percentage of red, green, and move the cross hair, slide the triangular pointer, or change the numerical values

t u select your color, use either the Apply or App ies the olo c

bin he spin boxes until you see a color you like. Once yo

ly to All button as desired. The Apply button affects the current slide, while Apply to All applr s heme to all slides in the current presentation. c

OFILMK

63

Bac Click the do

kground

Use this dialog to apply a custom background to one or all of your slides. wn triangle to display more colors or special fill effects.

Page 65: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Apply Design Use this selection to pick a slide design template from a list of 17

different designs. You can also click the Advanced button to 'find a presentation or template file. Then, you can apply the

g slide presentation to the current presentation. The Advanced Find dialog is shown n the next page. Notice that this dialog finds files that contain specified values, such as one or more

format of an existinowords used in a title or text.

The Header and Footer Dialogs The View Header and Footer menu selection, shown here, displays the Header and Footer dialogs. There are two dialogs tabs: Slide and Notes and Handouts.

e current slide; click Apply to All to add to every slide in the current

The Slide Dialog Use the Slide dialog to add a date, slide number, and footer text. The Preview box shows you what's been added. Notice that you can suppress your footer on the title (first) slide by clicking the Don't show on title slide check box. Click Apply to apply to thpresentation.

OFILMK

64

Page 66: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Tip: If footer elements interfere with text or graphics on one or more slides, display the affected slide. Then open the Header and Footer dialog, uncheck the Footer check box, and click Apply (rather than Apply to All).

The Notes and Handouts Dialog

se the NU o douts dialog ders and footers to your notes and printed handouts. otice that this dialog is similar to the Slide dialog, except that it permits you to add a header also. To

e results o ia N ew, type n . Any added headers and r

tes and Han to add heaNsee th f this d log, go to the

footers appeaotes Pages Vi

in this view. where you can your prese tation notes

I Obj licat The Tool Set

mporting ects from Other App ions

OFILMK

65

Page 67: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

66

LY

n the Standard toolbar as shown on the adjoining illustration.

N t th p of selectio e In u provides options for inserting a variety of items. There are equivalent buttons on the toolbar, as well. From left to right, b with the rt Microsoft Word Table button, you can click to inser t, a chart, or a an ert s presentations ile ides tline menu s . F phs guide y h the ion of each of these featu Clip Art Office 97's cl to int as s the other O ap r using ls PowerPoint Central election to access clip art, media clips, and other resources over the

e Insert Clip Art menu selection), the ialog is displayed.

ike many controls, PowerPoint gives you alternative ways to insert objects from external resources. ou can use the Insert menu or buttons

o

otice tha e bottom grou ns on th sert men

eginning Inset a Word table, Excel workshee

clip art picture. You c using the Slides from F

also inss and Sl

lides from existingfrom Ou

elections ollowing paragra ou throug operatres.

ip art library is available PowerPo well affice 97 plications. Conside the Too

sworld wide web. Therefore, you have a good assortment of resources from which to choose. To insert clip art, display a slide in the Slide View.

he first time you click the Insert Clip Art button (or use thTfollowing d

Pick the clip art, picture, sound, or video clip of your choice and click Insert. The selected object is

n your slide. placed o Notice that this dialog includes a list of categories and a clip art gallery. Simply select a category or scroll through the gallery until you find the clip art you want. Click the picture and then, Insert, or double-click the picture itself and it is inserted on the current slide. Once it's on the slide, you can drag it, scale it, or even cut and paste it as with other objects.

Page 68: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Printing Slides You can print all slides in a presentation, a range of slides, the current slide, or your notes, or handouts using the File Print dialog box.

Notice that the check boxes at the bottom of the dialoappearance of your printed slides. Also, you can print mselections in the Print what pick list. Finally, notice that y

g in the next illustration. These control the ultiple slides per page as handouts using the

ou can print multiple pages copies spin box.

serting a New Slide

new slide in a presentation: 1. Use the Slide view.

<Ctrl + M>. s ready for preparation.

py. 3. Press <Ctrl + C> to put it on the clipboard.

recede the inserted slide. 5. Press <Ctrl + V> to paste the slide following the selected one.

tations simultaneously Window Arrange All. Then display both presentations in the Slide Sorter view. Drag and drop

etween presentations as desired. close the source file

In To insert a

2. Display the slide preceding the point of insertion. 3. Click New Slide or use Insert New Slide or press4. Pick the slide layout and click OK. The new slide i

Alternate Method:

1. Display a presentation in the Slide Sorter view. 2. Click a slide to co

4. Click the slide that will p

Tip: This operation can be accomplished between two or more open presentation files by moving between the files using the Window menu. You can also display two presenusing bIf you drag a slide out of a presentation you don't want disturbed, be sure towithout saving when you are finished with it. Deleting a Slide

OFILMK

67

Page 69: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

68

To delete an existing slide from a presentation:

1. Display the slide in the Slide view. 2. Use Edit/Delete Slide to remove the slide.

one that is hidden from view by simply scrolling to it.

sert Slides From File

1. Open a new presentation. Files and select the desired presentation filename.

3. The presentation is inserted following the current slide.

4. Open the new presentation in either the Outline or Slide view. xt into the target outline or onto a new blank slide.

6. MICROSOFT ACCESS

Alternate Method:

1. Display the slide presentation in the Slide Sorter view. 2. Click on the unwanted slide to select it. 3. Press <Delete>.

Repositioning Slides

1. Display your presentation in the Slide Sorter view. 2. Click on a slide to be moved. Then drag and drop the selected slide into its new position.

Tip: Dragging to the top or bottom of the display causes the slides to scroll vertically. This feature allows you to drag a displayed slide in front of Integrating Slides from Other Presentations You can copy and paste slides from one presentation to another in a few different ways. Here's how. In Use Insert Slides from Files as follows:

2. Use Insert Slides from

4. Use Edit Delete Slide to remove all unwanted slides. 5. Use the Slide Sorter view to rearrange the slides as necessary. 6. Check the colors, transitions, and animation and touch up as necessary.

Insert Slides from Outline You can insert a slide from one outline to another as follows:

1. Display the source presentation file in the Outline view. 2. Click on the slide icon to select the entire passage. 3. Press <Ctrl+C> to copy the slide.

5. Press <Ctrl+ V> to insert the slide te Tip: Recall from above that you can drag or copy and paste slides between two or more presentation files using the Window menu.

Page 70: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

69

Wh Access is a Relational Database Management System (RDBMS) that is used by millions of people nagement programs are designed to store, manipulate, and report or data). Typical examples of data include the information that comprises a telephone and address directory, large inventory databases (or parts lists), order records, contact list mon misuse of spreadsheet programs is that of data storage. However, once people realize what can be done with a database management program, they realize theAccessoperati such as Windows 95 and Windows NT. As part of Office 97, Access uses a number of shared Office resources as do the other applications. These include fonts, ClipArt, spelling resources, As with eother Office and Windows programs. For example, you can insert Excel spreadsheet documents directlyportion of r program and then paste into an Access table. Or, you may prefer kind of doc ibility gives you the ability to work in ways that best suit your per

erms and Definitions

Database software comes with a lot of new terminology. Therefore, of this book provides a list of ommon terms and definitions that: should be useful. This section clarifies some definitions that are pecific Access. Here, you'll see the actual structure of a few different database tables. You also see ow they are created and how information is entered into tables and ultimately displayed. The creation nd use of these tables clarifies many database concepts in a relatively short time.

atabases and tables

Access, a database is a collection of information. Examples of database include private telephone irectories, lists of customers and suppliers, parts in a warehouse or store, and even private tape, ook, and compact disk collections. The information in an Access database is retained in tables. Tables

is called a record and pertains to a specific person or supplier, ontains a discrete element of information, called a field. A field

Thenum ege cod Las(S) me

at is Access?

around the world. Database malarge volumes of information (

s, and much more. A com

folly of storing large volumes of data in spreadsheets. Like the other programs in the Office 97 suite, makes use of all of the features available to programs designed specifically to run with a 32-bit ng system

AutoCorrect, and more.

th other Office programs, Access can also integrate documents and information created by

into an Access table. The ease and flexibility of doing this is impressive. For example, you cut a a document created by anothe

to "drag and drop" part of on into another using your mouse. Finally, you may simply important ument into another. This flex

sonal tastes.

T csha D

Indbconsist of rows and columns. Each row

ventory item, or event. Each column cinmight be a name, telephone number, stock-keeping unit number, unit cost, or any other piece of information. The following table example helps to illustrate records, fields, and some RDBMS concepts. A tennis and swim club must maintain a database for each of its members. Within the database different tables are used to store:

Names, addresses, and telephone numbers (Member table) Billing information (Billing table) Detailed purchases and fees (Fees table) Tennis proficiency ratings (Rating table)

first database table (Member table) contains names, member numbers, addresses, telephone de member name and privilbers, dates of birth, and membership dates. The number can inclu

es. For example, the first letter of the member number is the first letter of the member's last name. t letter of the member number designates whether the member has a tennis (T) or swim and social

mbership

Page 71: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

70

Number First Name Middle Name Last Name Spouse Name Address S1 ntry Club Dr. 465T John Kiran Rao Maria 1234 CouJ1050S e Sai Ram Vamshi Divya 1112 San Pedro AvenuS1300T 985 Trenton Circle Seetha Maha Laxmi Devi Rama

City State Postal Code Home Phone Work Phone Birth date Join date Hyderabad AP 500-001 (040) 555-7890 (040) 232-2323 10/21/37 5/1/78 Chennai TN 600-001 (044) 555556 (044) 222-3333 1/24/63 6/1190 Kolkata WB 700-010 (033) 555-1227 (033) 423-0908 3/4-9/50 11/1/86

The first line in the preceding table displays the name of each field. Then, three member records are shown. Notice how each field contains a different value, such as a member number, name, and address. Note: The field list could be expanded to contain other information such as children names and ages, other affiliations, etc. The Billing table contains billing information. Here, the total monthly charge accrued to each member's account is maintained. This is used as a basis for each member's monthly bill. It maintains the member number, total monthly charge, invoice date, and the date that the member's payment is received.

Number Amount Invoice Date Payment Date Amount Received Past Due

J1050S 209.90 05/31197 00/00/00 0.00 209.90S1300T 210.00 05/31197 06/08/97 210.00 0.00S1465T 270.00 05/31/97 06/05/97 270.00 0.00 The b ble that itemizes membership charges for dues, foocan be

Number Description Date Amount

illing information is derived from a third Fees tad and beverages, league fees, tournament fees, pro shop merchandise, and other charges. These

itemized on the member's monthly statement.

J1 5/31/97 35.00050S Dues for May J1050S Service, Massage 5/01/97 5.00J1050 5/05/97 16.40S Food & Beverage S1300T Pro Shop, Merchandise 5/31/97 148.50S1300T . Dues for May 5/31/97 125.00S1300t League Fee 5/31/97 25.00S1465T Dues for May 5/31/97 125.00S1465T Guest Fee 5/22/97 5.00S1465T Pro Shop, Merchandise 5/22/97 22.50S1465T Pro Shop, Lesson 5/28/97 25.00

Page 72: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

71

Finally, a Rating table is used to maintain tennis proficiency ratings for the tennis members. The ratings are used to place tennis members in the appropriate leagues. Number Date Rating Rated By Comments S1300T 01/30/97 3.5 L. Byers Needs to improve backhand S1465T xt league level 02/06/97 4.0 L. Byers Move to neJ1200T 03/16/97 3.0 L. Byers Schedule lessons A10BOT 04/12/97 4.0 L. yers Strong serve and volley S1465T 02/06/97 4.5 L. Byers Nominate for 5.0 team

A unique field is used to tie all four databases together. The Name field might be considered, but there could be two or more members with the same name. Therefore, the Number field is used, because no two members have the same number. Requests for information, or queries, can be made based on the member number. All four tables can be joined as if each member had one big record. However, since swim members don't have tennis proficiency ratings, there's no point in reserving space for empty fields. The same fact holds true for purchases. In addition to the member number, all that's needed is the date, purchase amount, and a brief item description. Adding fields for the member's address, phone num a waste of disk space. T r number is used to tie charges in the Fees table to the Billing and Member tables.

Sim the rating, and comments. T and

For

For format. For example, ou ere, you've omitted em e need

with t signed and saved, you Query

Simplydes ne ze and display information to answer certain questions. You can use queries to display infor as a member's number, name, amount due, and tennis rati f mation from three different tables; a query is also referred to as a dynaset. A dynaset is a dynamic tabReport Reports are used to display and/or print information. With Access we can produce spectacular reports by including graphics, charts and a variety of type styles and fonts. These features give Access many advantages over the old, DOS-based flat file database programs. Like a query, a report is also a dynaset as it is dependent on the current contents of supporting tables. Table Contents and Table Design

ber, or date of birth to each purchase record would be a duplication of information and therefore his information already exists in the Member table. Therefore, the membe

ilarly, the Rating table contains member numbers, dates, ratings, the name of the person doing ennis ratings are used to place players at the proper level for both tournament

league play.

ms ms are designed to display certain fields and descriptive labels in a convenient can create a form that contains member names and telephone numbers. Hy

m b r number, address, and age information. A form lets you focus on the information youou cluttering up the screen or printed output with unwanted text. Once a form is de

can open and use it to add, edit, or delete information within the corresponding table.

stated, a query is used to display information that resides in one or more tables. Queries are d to organiig

mation from multiple tables suchng. This query extracts in or

set of information that changes with the contents of the supporting le. Queries extract and display information they are not used to change information.

s

Page 73: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

72

You may have noticed that the toolbars and menu selections change when you switch between the Table view and Design view. Access displays the tool bar and menu selections that correspond to the task being performed. A descriptive button label is displayed when you position the mouse cursor on a toolbar button. You can also use the View Tool bars selection to display and hide tool bars at will. The View Toolbars menu selection and accompanying dialog is shown here. Too Use Vi avaope i

may want to display the toolbars and

d Once aunwantbutton (or double-click t me). The table is displayed in the Table view. Add, Cut, Copy and Paste You can add records by moving to the last row of a table and typing the

Edifrom the

in hen you use the

on.

olumns, and Freezing Columns

lbars

ew Toolbars to see the names of each of the ilable toolbars that correspond to the current rat on. The Toolbars dialog box lets you hide or

clicking the toolbar name. You show any of the listed toolbars bythen display each button name using your mouse. Each toolbar button has a corresponding name label. Display button names by moving the mouse cursor on the desired button. You can also customize your toolbar buttons as with other Office applications by dragging and dropping the desired buttons to and from a selected toolbar. A ding and Editing Records

table has been designed and saved. It's a simple matter to add new information, delete ed information or change existing information. Just pick the table name and click the Open

he table na

new record information. You can also delete records or change the information within the table just as you would within a word processor. You can rearrange the way that information is displayed - insert new fields, delete unwanted ones and much more. The Edit menu - which varies with the task at hand gives you the ability to cut, copy or paste information to and from the Windows Clipboard - just as you would with any Windows-based word processor. Spreadsheet or graphics program. You can also position the cursor and use Insert Row to insert a new blank row ahead of the selected one. The Delete

ow selection eliminates the current record. R

t Paste Special - The Paste Special selection is used to paste information n this is done other applications via the Windows Clipboard. Whe

dows Dynamic Data Linking (DDL) feature is used. WWoriginal application such as Excel or PowerPoint to make changes to the source information. Those changes are dynamically linked to the information (or graphic) used

ses the most recent informatiby Access. Hence, Access always u Changing Column Widths, Hiding C The width of a column is changed by placing the mouse cursor between column headings so that the cursor changes to a double-headed arrow. Press the left mouse button and drag the column margin left or right. Releasing the mouse button leaves the column in its new

Page 74: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

73

location. Use the Format Hide Columns and Show Columns selection to suppress and return the

more selected columns in place at the left edge of the screen as

edg d out of view. To return to normal scrolling,

se the View menu to display the Table view, Design view, or to display or hide selected toolbars. Use

ign and modification of tables, queries, forms, and ports t's easy to change the design and properties of a table. This is done by picking the table name

nd then clicking the Design button. Once the structure is displayed, you can change field lengths and

ies, Access tells you nd gives you the opportunity to make necessary changes to your contents. For example, if you change

the Requir the table. Finally, use Edit Set Primary Key (or the Set Primary Key button) to designate a field as a primary keNumber field in the Member table and the ID AutoNumber type fields are examples of primary key elds. You can not have more than one primary key field in a table.

reating Relationships between Tables

s. In the Club atabase, the Number field is an indexed field in all tables. It is the primary field in the Member table.

sh a between the N in the Member and Fees, Billing, and Rating ceed

k the play th2. Use the Tools Relationships menu o yed,

pick each of the four table names an

PickPick Billing

c. Pick Fees and click Add. d. Pick Rating and click Add.

able boxes so they are llowing illustration. (The ''join lines" are added in

ips) as follows: a. Pick Number in the Member box, drag to Number within the Billing box, and release the

ton. Click Create in the second Relationships dialog box. lling box, drag to Number within the Fees box, and release the mouse

display of selected columns. Use the Format Freeze Columns and Unfreeze All.

Columns selection to keep one or others are scrolled left and right. For example, you might want to keep the member names at the left

e of the screen while looking at information that is scrolleuse Unfreeze All Columns.

Uthe View Options selection to set the way information is displayed. Changing Table Properties Access gives you a great deal of flexibility in the desre . Iaformats, insert new fields, delete existing ones, and more. Once your changes are made, save the changed properties. If the data within the table doesn't adhere to the new properta

ed property from No to Yes and a blank field exists, you can make the change before saving

y field. A primary key field is unique and prevents you from having duplicate records. The

fi C You can establish relationships between two or more tables by associating common fielddTo establi relationship umber fields tables, pro as follows.

1. Pic Club database to dis e database window (if not already displayed).

ption to display the Show Table dialog box. Once displad click Add as follows:

a. b.

Member and click Add. and click Add.

ble dialog box by clicking Close. Now drag the t3. Close the Add Ta

positioned approximately as shown in the fostep 4.)

4. Establish the join lines (or relationsh

mouse butb. Pick Number in the Bi

button. Click Create.

Page 75: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

74

c. Pick Number in the Member box, drag to Number within the Fees box, and release the

ber within the Rating box, and release the

5. Verify that your join lines resemble those shown in the illustration. Then use File Close and

Adding OLE Object Fields to a Table It is an easy matter to add an OLE object, such as a picture or chart created by another Windows application, to an Access table. Once the object is linked, it can be displayed in forms and reports. Access simply "fetches" the linked object and uses it as directed. Use the following procedure to add an OLE object field named Picture to he Members table. Note that the pictures are simple bmp graphic les; However, they could be scanned photographs, maps, and more. Begin with the Club: Database

ndows 95 Explorer to ensure that the following files are present in your C:\MSOffice\Files folder: JI050S.bmp, S1300T.bmp, S1465T.bmp. Then close the Explorer.

3. list as follows: Type Picture in the Field Name column, click OLE Object as the Data Type, and type Member photo in the Description column. Press

4. button to display the Member table. Scroll right to the new Picture column (or press <End>).

rt Object dialog box, click Create from File button, and put a check in the Link check box. Now click Browse to locate the

click Open and then OK.

Notif a dra el worksheet is linked to a table, you can use the originating program to hange the map or worksheet source file. These changes take effect instantly when viewed within the

link

mouse button. Click Create. d. Pick Number in the Member box, drag to Num

mouse button. Click Create.

click Yes to save the relationships.

tfiwindow displayed, and proceed as follows to add "pictures" of your members.

1. Use the Wi

2. Click the Tables tab, pick Member, and click the Design button. Add a new field to the bottom of the field

<Ctrl + S> to save the table. Click the Table view

5. Pick on each row of the Picture column and insert picture objects as follows:

a. Pick the Picture field on the first row (Johnson's record). b. Use Insert Object to display the Inse

C:\MSOffice\Files\J1050S.bmp file as shown in the following illustration. Pick the file and

e that linking the object causes changes to the source file to be reflected in the table. For example,

wing of a map or an Excc

ed Access table.

Page 76: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

75

Tip: There are other ways to insert OLE objects into a table. For example, you could have used the Explorer to find a file, double-click on it to launch it parent application, and select and copy it to the clipboard. Once an object is on the clipboard, you can use Access Insert Object menu

le and then exit back to Access. Other object types (such as graphs and tables) and their controlling applications work in the same way.

p b for each. Use and S 1465T. bmp for the third row.

. Double-click on "Bitmap Image" within the Picture column to display the pictures in Paint. Each

s

selection to pick Bitmap Image. This launches Paint, where you can either draw a new picture or paste the contents of the clipboard into the Paint window. Then use the File menu to update the tab

c. Pick the Picture field on the second row and then the third row, performing stethe S BOOT. bmp graphic file for the second row

6should resemble the following illustration.

7. the table. Use File Exit

Member pictures have now been linked to each record in your Member table. Creating queries Usi TheNumbeFee a tab mplex queries

Press <Ctrl + S> to save your to exit the Access program.

changes; then use File Close to close

ng the Query Window

following procedure guides you through the creation of a simple query. In this query you display the r and Name fields from the Member table and the Date, Description, and Date fields from the ble. This lets you review each member's number, nams t e, and charges using the contents of two

les. Of course, you can also design simple queries that involve a single table or co

Page 77: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

76

thaClub.mdb database open.

. Click the Queries tab. With the Queries tab selected, click New; notice that the New Query dialog is displayed. Review the displayed choices.

t involve many tables. To perform the following procedure, begin with Access running and the

1

Point of Interest: Query Wizards are useful if you wish to create one of the following query types:

The Design View requires that you manually sele ach field to a blank desktop.

A Simple Query lets you sele set of dialogs. A Cross tab Query Wizard totals both rows and columns.

A Find Duplicates Query Wizard finds all records within a table having a duplicate value.

In this activity you design your query using the Simple Query Wizard selection.

2.

3. Pick Member from the Tables/Queries list and then put Number, First Name, and Last Name e Selected Fields: list using the > button. Then put the following Fees fields into the

ct each table and add e

ct tables and fields from a simple

A Find Unmatched Query Wizard finds all unique records within a table.

Pick Simple Query Wizard and click OK to display the Simple Query Wizard dialog.

in thSelected Fields list: Date, Description, and Amount. Compare your display to the following illustration.

Page 78: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

4. Click Next>. Check that the "Detail" button is selected then click Next to display the next Simple Query Wizard dialog.

5. Type Fees1 as the query title. Leave the "Open the query to view information" button selected

and click Finish to display your first query view.

Query Design menu to switch views.)

cided to create your query from scratch, you would have picked the

names (in the form table. field) are put in each column one by one. You can also drag and drop field nam boxes to the desired columns of the query.

query shows information from two tables, Members and ~. Also, see how the rouped together; Notice the check box in the Show row. A check mark in

this box tells Access to show the field (or current column) n your query an empty box tells

6. Click the View button to display the Query Design view with field and table names. (You can also use the View

TIP : Point of Interest: If you had deinvolved table names and then the individual field names from each table box. The table and field

es from the table

7. Notice that themember numbers are g

Access to hide the field.

section you developed a relationship between the Member and Fees r field. This automatically establishes a join line between the Number fields

f each table. (Notice the join line between the Member and Fees table boxes. Also notice how primary key fierelationship create a join line on the fly by picking the key field in the first table and then dr

Point of Interest: In the last tables based on the Numbeo

lds are displayed in boldface type in each table box.) If you had failed to establish the there, you could

agging to a matching field in the second table.

OFILMK

77

Page 79: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

78

8. Move the cursor down to the Sort row of the first (Number) column. Pick the down arrow button and select Ascending to sort queried member numbers from A to Z.

9. ng display. Adjust co necessary. Notice that the Number field is sorted in ascending order. The resulting i what is referred to as a dynaset, i.e., a dynamic set of data that changes w in the supporting tables.

sing Criteria and Saving Queries.

Using crite Now that you have designed the ba y, you can refine it by restricting what is displayed using the Criteria the me esteps:

1. Clic hCrit

2. Type "JI050S" (includin

notice that o son's information is displayed. ates are in random order. Put them in ascending order by returning to the Design

ing in the Date's Sort row. Then return to the query view to see the result.

two member numbers by putting a second number on the criteria

/97

e form:

ou can put the expression in a zoom window then pressing <Shift+F2>.

. w and delete the Criteria from the Number column.

nd Operators

scription

Click Query View and examine the resulti

lumn widths asnformation is a simple form of ith the information contained

U

ria and saving queries

sis of a querrows. For example, if you just want to see the charges for a single member, you can enter

mb r's number on the Criteria row of the Number column. Try this by performing the following

k t e View button (or pick View Query Design from the menu) then put the cursor on the eria row of the Number column.

g the quotation marks). Now click the View button to see the query and nly Bill John

3. Notice that the dview and placing Ascend

Points of Interest: You can also display

row, such as "JI050S" or "S1300T'. You can display all of the entries for the month of May by using an expression in the Criteria row of the Date column such as: Between 5/1/97 And 5/31

ccess converts this expression for you to thA

Between #5/1/97# And #5/31/97# To view and edit a lengthy expression, y

y positioning the cursor in the desired Criteria cell andb

4 Switch back to the Query Design vie 5. Press <Ctrl + S> to save the new Fees1 query. Then press <Ctrl + W> to close the

query. Criteria Expressions a Criteria expressions and operators used on the Field row include a combination of operators, identifiers, functions, literal values, and constants. These are briefly described in the following table. Element Examples DeOperator =, <, +, &, And, Or Performs an operation on one or more elements

ssion. within an expreIdentifie ol, or property. r Forms![Charges]!Amount References the value of a field, contrFunctio ponding to the results of a

ctions can also be n Date, Sum, DCount Returns a value corres

calculation or other operation. Fun

Page 80: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

created using the Access Basic language. Literal 24.95, #5/31/97# A number, date, or text entry (called string). Constant Null, True, False, Yes, A fixed value that do

No esn't change

Example: [Date] Between #5/1/97# And #5/31/97# Operators: And Identifiers: [Date] (identifies a field name) Literal: #5/1/97#, #5/31/97# Entry Conventions Access uses the following conventions for objects, such as field names, dates, and text strings.

Dates are entered within number signs (#). are entered within quotation marks (")

Object names are typed within square brackets ([ ])

you omit the numbe igns, quotes, or brackets, Access often inserts them for you.

and Totaling It is easy to edit que ies. In fact, you can open an existing query, make changes, and then use File Save As to save the changed query under a new name. You can also create queries based on existing queries. In the previous query that you saved as Fees1, you could have established a Date criteria to display all transactions for the month of May 1997. If you wish to display a total of each member's charges for the month of May, you can quickly create a dependent query that is based on one or more fields of the Fees1 query. Dependent queries are often referred to as nested queries.

Text strings

If r s Changing a Query

r

In the following activity uery to display th ch member's charges for

e month of May. Begin with the Club database still open and the Queries tab displayed. Now perform steps.

esign View. Then click OK. Pick the Queries tab. Your screen should

you develop a nested q e sum of eaththe following

1. Click New and pick Ddisplay the following Show Table dialog.

2. Click Add and then click Close. Notice that a Fees1 query box is displayed above the empty

query design table.

OFILMK

79

Page 81: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

3. From left to right, insert the Number, Last Name, Date, and Amount fields on the Field row. (Either drag the name from the Fees1 box to the appropriate column on the Field row, or

5. Move the cursor to the Total row in the Amount column, Click the down arrow button and pick k list.

6.

double-click the field name in the Fees! box. You can also click the down arrow button, and pick the appropriate field name from the pick list.)

4. Click the ∑ button to insert a Total row. Notice that each column has "Group By; on the Total

row.

Sum from the pic

Move the cursor to the Total row in the Date column. Click the down arrow button and pick Count from the pick list. Your query design should resemble the following illustration.

7. Click the view button and compare the query to the following illustration.

Notice how number of dates, and hence transactions, for each member nu e SumOfAmount column contains the sum of each member's charges.

8. Pick Fees1 in the Query Name box, and click OK. 9. Pres

ueries is a simple matter using the power of Access. The preceding activity lso shows you how to use a nested query, i.e., one query that is based on another query.

the CountOfDate column displays the mber. Also see how th

File Save, type the names <Ctrl + W> to close the new Fees1 query.

As you can see, building qa

OFILMK

80

Page 82: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

81

Findin

o find a value, use the following general procedure:

1. Find).

3. Set the Search to All, Down, or Up. Up and Down tells Access to search backward or forward in

4. Set the Match to: Field-This is a substring search, i.e., "ox" finds box and lox.

e field. Start of Field-Search string must match the first part of the value, i.e., "Jo" finds Jones and Johnson.

g information in a database Finding values

T

Display the table, query, or form. 2. Click the field to search and press <Ctrl + F> (or use Edit

the table, query, or form.

Any Part ofWhole Field-Search string must match the entire value contained in th

5. Set the Match Case check box-Constrains the search to match uppercase and lowercase within

6. et the Search Fields As Formatted check box-Search as displayed rather than the source r the

check box. 7. Uncheck the eld box to extend your searches to all fields. 8. ex d either the next or first occurrence of the find

9. butt

Creating Filters You can also find informati ters, criteria used to control what is displayed or printed by a form. Filters bles cted within a field (filter by selection) or use an advanced filtering technique that can use multiple fields (filter by for Sel k at specified information. The last Filter-By-Form criteria used ty in this section steps you through the use of Filter in which a fi

the search string. Svalue. For example, the date value 1/10/97 is formatted to display as 10-Jan-97. Entesearch string as displayed when using this

Search Only Current Filick the Find NC

value. t or Find First button to fin

Click the Close on to discontinue the find operation.

on using fil operate with ta , queries, and forms. You can filter information based on a value sele

m) The Filter By ection criteria is temporary in nature; it is used for a fast, interactive loose filters disappear when the form is closed. On the other hand, the are maintained. The last activi

By Form lter is saved for reuse.

Page 83: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

82

INFORMIX

7. RDBMS CONCEPTS

particular one is called Data. Singularly called as datum.

s marks is called Data where as total marks,

Database ored together in a location is called a

database. It re the require . Traditi al Fi

In a conve e nal FMS are :-

l /Program independence. • cation hence data inconsistency

• o • Mu• No by any one and modify/delete it.

The sing a DBMS/RDBMS packages.

BMS (Data Base Management System)

x. For DBMS :

b. FOXBASE c.

Data Collection of information about some

Information The processed data is called information. Ex. Student

erag av e marks are called information,

A collection of logically interrelated data that are to be st is an electronic filling cabinet. Finally we can define it as “it is a base” from whe

d data is stored and retrieved

on le Management System

(Conventional File Management System) ntional file system, the data is stored in a ordinary file as a bulk amount. Th

disadvantages/drawbacks in traditio

• Lack of data definitionaData Redundancy - repetition of same data in different lo

roblems pN Data Integrity.

lti - user issues fully supported. Security for data – the data file can be opened

se disadvantages can overcome by u

D

A DBMS is a layer of software (package) between the Computer System and the user use to create and managing the database effectively, and provide users with an abstract view of the data, i.e. the system hide details of how the data is stored and maintained. E

a. dBASE

FOXPRO d. MS-ACCESS Etc.

Page 84: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

83

RDBMS: Relational Database Management System: which is most advanced and powerful package an a DBMS package:

Ex: RDBMS P

A. ORACB. SYSBAC. INGRED. INFOR

Operation tha ase

th

ackages

LE SE SS MIX

t can be performed on a datab

Wha e are certain basic operations that are an be performed:

Cre d Ent Modifying data when it changes Rem Extracting data in various forms and combinations Ens rity of the data

A datab S is a collection of programs which using the facility of

the operating s ipulate the database in the ways mentioned above.

Disadvantage

1. High cost of DBMS software & Hardware. Lot of disk space, powerful process additional

s database users

mmer 3. Database Administrator

er: The Application programmer is responsible for developing es) by using languages like C, C++, COBOL etc. These

rieve data from database.

tever form a database may take, thes

ating a structure in which thering data into that structure

data is to storee

oving obsolete data

uring consistency, security and integ

ase management system or DBMmanystem, enables the users to

s Of DBMS

memory required. 2. Developing is simple but lot of time & through has to be shed for design. 3. Once database fails all activities come to a standstill. Adequate backup can solve problem.

Types of Database users

They are of three type

1. End User 2. Application progra

1. End user: The End user uses the database by using a database query language (like

SQL). He is allowed to perform basics operations like insert, delete, and update and retrieval data from a date base.

2. Application Programm

ammApplications (progrprogrammes are used to ret

Page 85: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

84

3. Data Base Administrator: DBA is the Administrator for the Database. The DBA is information about the data to be stored, designing and

he database security is also one of the major responsibility of

Databa

. OBJECT-BASED LOGICAL MODELS

e defined as a collection of conceptual tools for describing data,

DELS

es the data structures and access techniques of a DBMS.

An Entity is a thing which can be easily identified. En Entity is an object, place, person, concept, ords the data. Entity names should be always in capital

letters, Ex. STUDENT, EMPLOYEE, COURSE, OFILMEDAK etc. RE

Relationship is an association among Entities or It a condition to join one or more Entities. A en entities.

.

a. One-to-One Relationship ex. Husband : Wife hildren

of DBMS data models:

responsible for collecting the maintaining the database. TDBA.

se Models A

The object-based model can b

data relationship and data constraints. B. RECORD - BASED LOGICAL MO

The record-based model describ C. ENTITY – RELATIONSHIP MODEL (E-R MODEL) ENTITY

activity or a thing about which an enterprise rec

LATIONSHIPS

relationship can be established betwe There are mainly three types of relationships

b. One-to-Many ex. Parent : Cc. Many-to-Many ex. Many supplier supplying many parts

Types of RECORD BASE DATA MODELS There are three major categories

• Hierarchical • Network • Relational

Page 86: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

85

PRODUCTS DBMS DATA MODEL

HIERARCHICAL

IMS system 2000

NETWORK

Idms total

RELATIONAL

INGRES LE MIX

All data is presented to ORAC

INFOR

DB2 SQL/DS

HIERARCHICAL MODEL

A root data item heads the tree of the information, and all lower bits of related information are hes.

a

it allows many-to-many lationships.

sed to relate

like branc Lower level of data is retrieved by entering the file at the root and searching the inverted tree downwards. If the information is not found in the selected branch, the control must go up to the root and proceed down another branch

NETWORK MODEL

It is more flexible as compared to the hierarchical model as it uses pointers to repeat variouspieces of dat that make a record. The information is accessed much faster, as an index file is made use of allowing random access tot eh stored data. Less storage is required in this cases data redundancy is considerably reduced. Due to its complicated structure, this model requires data

anipulation through complicated query language. Its main advantage is that mre RELATIONAL MODEL

Here there are no predefined connections between data sets. Duplicate fields are uone data set to another. In addition, it supports many-to-many relationships. Data independence is achieved as tables can be changed without affecting the applications written against them. Unlike previous models, data is operated a ‘set’ at a time rather than a record at a time.

parent

Parent 1

Parent 1

child child

Grand child

Parent 1

Parent 1

Grand child

Page 87: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

86

AND RDBMS

The Relational model was first described by Dr. E.F. Codd in 1970. The Relational model was an attempt to simplify database structure. It represents all data in a simple rows and columns of a table.

Differences between DBMS

DBMS RDBMS The relation betmaintained programmatically, if required.

while ures itself.

ween two files has to be Relationship can be specified creating struct

Client/server architesupported

st DBM nt/server cture is not normally Mo R S support cliearchitecture

Distributed database is not supported Support Distributed databases Least security: anyone can access records.

Multiple level of security maintained :

Command level security Login security

Object level security Does not follow Codd's rules Follows many of the Codd's rules.

without duplica

Advantages of RDBMS

• • • • • Recovery from failure. •

Terminology TUPLE

Each row is called as a tuple.

TES The Columns are c

PRIMARY KEY

uniquely identified by means of a primary Key. Its value should be unique and not ull. Depending upon the relation it can be singular or composite.

Ex: In Employee table: The Personal No is primary key. CANDIDAT

A general objective of the database approach is that the database should be a natural representation of the data with few imposed restrictions, capable of use by all relevant applications,

tion.

Data Redundancy can be reduced. Data independence. Ensure access and integrity. Sharing data.

Uniform security and privacy through password, view and automatic backup.

of RDBMS

ATTRIBU

alled Attributes.

Each row isn

E KEY Another attribute (column), which is eligible to act as the primary key.

Page 88: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

87

FOREIGN KEY An attribute (Column) in the current table which is a primary key of some other table.

Ex: In Employee table, Dept Code/No is the foreign key. CARDINALITY

The number of tuples in a table is the Cardinality factor of the relation.

IN It is the ran

elations Operat

e relatioollection of operators th

AT

DOMA

ge or pool of values that particular attribute can support.

ors used in RDBMS R Th nal model is based on the solid foundation of relational algebra. It consists of a

at operate on relations. c

OPER ION MEANING RESTRICTION Extracts tuples or rows PROJECTION Extracts attributes or columns PRODUCT uilds a relation from two specified relations. BUNION Builds a relation from tuples appearing in either or both of the

specified relations. INTERSECT consisting of tuples that appear in the both the ION Builds a relation

relations. DIFFERENCE Builds a relation of tuples appearing in first but not the second of two

specified relations. JOIN Builds a relation from two specified relations consisting of all possible

combinations of tuples, one from each relation, such that two tuples satisfy the specified condition.

DIVIDE two relations, and builds another relation consisting of values of Takes an attribute of one relation that match all the values in the other relation. The DIVIDE operation is the opposite of PRODUCT.

Page 89: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

88

8. STRUCTURED QUERY LANGUAGE (SQL)

lat

rocedural language because it:

Inserting, updating, and deleting rows in a table. cts.

Controlling access to the database and its objects. nsistency and integrity.

e as follows:

nipulation Language statements (DML) anguage statements(DCL) tatements

Information ction

hich means that mitted to the database server. Unlike most programming into an executable program to run. Using an interface or

s operating. The following lists

nguage statements (DDL)

Introduction

SQL is simple, powerful database access language that is the standard language for many ional database management systems. re

SQL is a non-p

Processes sets of records rather than just one at a time. • Provides automatic navigation to the data. No need to specify the access method to the data. •

SQL provides commands for a variety of tasks including: • Querying data. • • Creating, replacing, altering, and dropping obje•• Guaranteeing database co

Types of SQL statements

SQL has many processing capabilities, which ar

1. Data Definition language statements (DDL) 2. Data Ma3. Data Control L

ity S4. Data Integr5. Query Optimization6. Client/server conne

One main feature of SQL is that statements can be processed interactively, w

an SQL statement is processed when it is subiled languages, SQL does not have to be comp

other program, SQL commands can be executed while the system idescribe each of the processing statements.

Data Definition la The following Data Definition Statements (Language) (DDL) allow creation of the database and

he data structures for the system: t

Page 90: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

89

DATABASE

SE DEX

EDURE EDURE FROM

OLE

YM TABLE

RIGGER IEW

DROP DATABASE INDEX PROCEDURE

YM

SE

Data M L)

The following data manipulation statements (DML) allow you to add, delete, modify, and query ata in the database:

L

ata C ntrol

The following Data Control Language [DCL (data access statements)] are use to determine the ccess of the data. Such access is used in case of permissions and data security.

ALTER FRAGMENT INDEX TABLE CLOSE CREATE DATABA IN PROC PROC R SCHEMA SYNON T V

SYNON TABLE TRIGGER VIEW RENAME COLUMN DATABA TABLE

anipulation Language statements (DM

d

DELETE INSERT

OAD SELECT

UNLOAD UPDATE

D o Language (DCL)

a

GRANT LOCK TABLE

REVOKE SET ISOLATION

SET LOCK MODE SET ROLE

Page 91: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

90

TION Data i

The following data integrity statements are used to ensure the data’s integrity. These

tatements ensure that the data is safe and is tracked in multiple places:

BEGIN WORK

CREATE AUDIT

ROLLBACK WORK

START DATABASE

Query The following ation information statements are used to gather information on the

ese are great to use when trying to investigate why a certain SQL rove it.

SET EX

SET O SET PDQ PRIORITY

In relation database systems such as Informix, the data is organised and stored in tables or entities

ances. Columns are the vertical parts of the table, which are also known as attributes. ables, rows, columns are a way of organizing the data and giving you an understanding of a relational odel.

ATA PES

The process of organizing data brings you to the definition or value that can be stored in the columns of a table. Table shows the data types that are supported by Informix.

SET SESSION AUTHORIZA SET TRANSACTION UNLOCK TABLE ntegrity Statements

s

CHECK TABLE COMMIT WORK

DROP AUDIT RECOVER TABLE REPAIR TABLE

ROLL FORWARD DATABASE SET CONSTRAINTS SET LOG

optimization information statements

query optimizquery in execution. Thstatement runs a very long time and how to imp

PLAIN PTIMIZATION

SET STATISTICS Client/Server connection statements

The following client/server connection statements are used to establish application connection

for a specific environment and/or database CONNECT DISCONNECT SET CONNECTION

, which are just a collection of columns and rows. Rows are the horizontal parts of the table also referred to as instTm D TY SUPPORTED BY INFORMIX

Page 92: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

91

Data Type Definition BYTE Stores binary data.

res letter, numbers, and special characters.

es calendar date.

DECIMAL Stores decimal numbers with digits of Numeric Precision.

DOUBLE PRECISION Stores double-precision floating numbers.

Precision floating numbers.

–2,147,483 to 2,147,647.

ion.

es a native string of letters, numbers, and special characters.

NVARC

data

th.

CHAR Sto

DATE Stor

DATETIME Stores calendars date with time of day.

FLOAT Stores double-

INTEGER Stores numbers ranging from

INTERVAL Stores span of time.

MONEY Stores currency amount.

NUMERIC Stores decimal numbers with numeric precis

NCHAR Stor

HAR Stores native character strings of varying length.

ERIAL Stores sequential integers. S

SMALLFLOAT Stores single-precision floating numbers.

SMALLINT Stores numbers ranges from –32,767 to 32,767.

TEXT Stores text

VARCHAR Stores characters string of varying leng

Serial. If you select the Serial data type you will be asked to specify a starting number (the value of the column when the first row is added to this table), which will default to 1 if you press return.

he starting number will be displayed under the Length heading.

is formatted on display ent variable. You will be asked for the length, which is the total

d the scale, which is the number of decimal digits.

Date-tin to fraction of a second, and you determine the precision

rough the ADD DATETIME QUALIFIER menu, which is displayed next.

T M . The Money data type is a special form of Decimal whichoneyaccording to the DBMONEY environmnumber of significant digits to be allowed for, an

me. The Date-time data type allows you to hold a value, which represents a precise moment in time. It can hold any value from a year dowth From the ADD DATEIME QUALIFIER menu you must select a first and last field for the precision, form the available choices. A standard DATE data type, for instance, where as a daily timestamp would have a precision for HOUR TO SECOND. If you wanted to store just the year, you could specify YEAR TO YEAR.

terval The Interval data type allows you to hold a value, which represents a precise span of ld any value from a year down to a fraction of a second, and you determine the precision D INTERVAL QUALIFIER menu, which is displayed next.

Intime. It can hothrough the AD

Page 93: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

92

From the ADD INTERVAL QUALIFIER menu you must select a First and Last field for the precision, from the available choices. There are two exclusive lists to choose from, either YEAR, Month, or DAY down to fraction. Each field represents a number of that particular field, as in a number of years or a number of days and hours. A work period might have a precision of HOUR TO MINUTE. If you wanted to store just a number of years, you could specify YEAR TO YEAR.

Variable-length With Informix-Online as your database engine you may select the Variable-length option, which

then displays the VARIABLE-LENGTH menu as shown in figure.

VARIABLE-LENGTH: Text Byte

Variable-length data containing maximum of 255 characters.

----page 1 of 1------------property------------------press CTRL-W for Help--------

Column Name Type length Index Nulls

Adrs2

VARCHAR Specify a maximum size that this column will accept, up to 255 characters, and a minimum

space which will always be reserved, from 0 to maximum. Use VARCHAR with caution, as updates, which exceed the minimum space, will impinge on performance.

Note :- [BLOBs – Binary Large Objects (online only)]

TEXT The ADD BLOBSPACE menu is displayed and you are asked whether you want to store the column data in the same dbspace as the rest of the database (the TABLE option), or in a separate BLOB space (the BLOB space-name option). Note :- [Up to 2Gigabyte of textual data (including tabs, returns and form feeds) may be stored in

this column.]

BYTE The ADD BLOBSPACE menu is displayed and you are asked whether you want to store the column data in the same dbspace as the rest of the database (the TABLE option), or in a separate BLOB space (the BLOB Space-name option). Note :-[Up to 2 Gigabytes of binary data may be stored in this type of column. The data may be

anything from spreadsheets and programs to digitised images and sound.]

The dbs chemautility exists to recreate the SQL command file used to create a table or tables in an existing database.

dbschema [-t tabname] –d database [filename] where filename contains the dbschema output.

At the Unix Prompt type as

QL Structured Query

anguage you must select the Query-Language option from the main menu. The SQL menu has ten ptions which allow you to create, modify, save and retrieve SQL command file, as well as running and

THE SQL MENU

$ ISQL

Then SQL Main Menu will be displayed. To use the INFORMIX-SLo

Page 94: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

93

deleting them. There are also options to output the result to the printer or a system file and to obtain formation on tables in the current database. The SQL menu provides various options are as follows:

in

NEW The New option is used to enter and edit SQL statements on the screen, using the SQL editor. Selecting this option also clears the current statements, without warning, so be sure to save them first with the save option if you think you may need them again.

RUN SQL statements. If errors are detected the Modify option is

sed instead. In either case the first Runs the current set ofhighlighted although the Use-editor option be uerror detected will be indicated.

ODIFYM Is used to change the current statements using the SQL editor. If an error is detected

of the error.

TOR

while running the current statements, the cursor points to the position USE-EDI Is used to enter and edit SQL statements on the screen using a system editor. Any

editor producing ASCII output and accepting a filename from the command line may the default may be changed by setting the environment variable be used but

DBEDIT. OUTPUT This option sends the result of running the current statements to the printer, a system

file, or another program. SAVE Is used to save the current set of SQL statements is a command file for later retrieval

using the Choose option. The extension .sql is added automatically.

HOOSEC Having saved a number of command files, you may select the contents of one of e them to be current statements by selecting the CHOOSE option. You may omit th

.sql extension. INFO The Info option gives a wealth of information ab

indexes. out the current database tables and

DROP

d file from the list of command files.

XIT

Allows the user to delete a comman E Returns you to the INFORMIX.SQL main menu.

Entering & Executing/Run SQL commands

. Type 1 isql at the Unix prompt then it open the Informix SQL and the main Menu will be displayed as follows.

INFORMIX-SQL: Form Report Query-Language User-menu Database Table Exit Use Informix Structured Query Language 2. Select Query-Language and select the Informix Database, if no database is selected.

ollows.(assume deva is the database name) Then it

display SQL screen as fSQL: New Run Modi ose Save Info Drop Exit fy Use-editor Output ChoEnter new SQL statements using the SQL editor. ----------------------- deva@ for Help -------- tvr --------------- Press CTRL-W

Page 95: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

94

3. Click New and type4. After command ent5. Finally Select Run be executed and the

result of the comma ttom of the screen.

If any error occurre e L statement and again select Run to execute it. Creating a database

A database is th data model together. The parts include the tables, views, and in can be created.

By using the com lly resides in one dbspace as specifie e is created in the root dbspace by pecify what type of logging you want for the database. Following statement cre

E DATAB

g statement cre CREATE DATABASE d 1 IN dbspace1 INFORMIX-Online offers

• Unbuffere

The following statements specify the atabase at creation time:

CRATE DATABAE dataCRATE TABAE database1 WITH LOG CRATE

CREATE TABLE to define table in SQL. To create a table you must

The CREAT atement is used to create all tables defined in the data model. When

re pply the following information:

the SQL command ry is Over Press ‘Esc’ Key to close the entry. to run/execute the command, then the SQL command willnd will be displayed at the bo

d s lect Modify to modify the SQ

e object that holds all the parts of yourdexes. You must create the database before anything else

mand CREATE DATABASE SQL statement. The database usua

d in the statement, but if no dbspace name is specified, the databas default. In crate we can also s

ates a database in the root dbspace:

CREAT ASE database1 Followin ates a database in the specific dbspace:

atabase

four types of transaction logging. They are

• None d

• Buffered• ANSI-Compliant

type of logging on the d

base1 WITH NO LOG DA DATABAE database1 IN dbspace1 WITH BUFFERED LOG

CRATE DATABAE database1 IN dbspace1 WITH LOG MODE ANSI Create A TABLE

SQL provides the statement have CREATE TABLE system privilege.

E TABLE st

you c ate the table, you define the columns and su

Page 96: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

95

• Column name

Prim E constraints for not allowing

duplicates

Not Null constraint

• constraint

• Lock mode option

Syntax :

CREATE TABLE tablename (column1 datatype(size) constraint,

e),……);

A table emp can be created as follows:

(empno NUMBER(4),

job VARCHAR2(9));

reate Table with Constraints

able SALGRADE with constraints

CREATE TABLE salgrade grade NUMBER CONSTRAINT pk_salgrade PRIMARY KEY,

losal NUMBER(9,2), hisal NUMBER (9,2));

EGRITY CONSTRAINTS

t types of integrity constraints

s.

• UNIQUE key constraints

• Data type for each column

• ary key constraint on one or more columns and the UNIQU

• Foreign key constraint for one or more columns

• Default value constraint

Check

• FRAGEMENT By option

• Extent option

• Logging option

column2 datatype(siz

Eg.

CREATE TABLE emp1

ename VARCHAR2(10),

C

To define the sample t

(

DATA INT The differen

• NOT NULL constraint

Page 97: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

96

• PRIMARY KEY constraints.

• FOREIGN KEY (referential) constraints.

• CHECK constraints.

NOT N

y ULL or NULL, the column can contain nulls by

efault.

You can only specify NOT NULL or NULL with column_constraint syntax in a CREATE TABLE with table_constraint syntax.

name] NOT NULL,

NULL,

NIQU KEY

i r combination of columns as a unique key. To have the same value for the unique key. tain nulls.

atype LONG or LONG RAW. The same column or oth a unique key and a primary key or as both a

mn or combination or columns can be designated .

PT table and defines and enables a unique key or the

CREATE TABLE dept (2),

AINT unq_dname UNIQUE,

ULL INTEGRITY CONSTRAINTS

NOT NULL constraint specifies that a column cannot contain nulls. To satisfy this constraint,

every row in the table must contain a value for the column.

The NULL keyboard indicates that a column can contain nulls. It does not actually define anintegrity constraint. If you do not specify either NOT Nd

or ALTER TABLE statement, not

Syntax : CREATE TABLE table_name

(col1 datatype(size) [ constraint_COL2……);

Eg. CREATE TABLE emp (empno number(4) NOTename varchar2(20), job varchar2(10));

U E CONSTRAINTS

The UNIQUE constra nt designates a column osatisfy a UNIQUE constraint, no two rows in the table can

er, the unique key made up of a single column can conHowev

An unique key column cannot be of datation of columns cannot be designated ascombin b

unique key and a cluster key. However, the same coluas both a unique key and a foreign key

The following statement creates the DEDNAME column: (deptno NUMBER dname VARCHAR2(9) CONSTR LOC VARCHAR2(10));

Page 98: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

97

Note : The constraint unq_dname identifies the dname column as a unique key.

ls unique Constraint):

ables a composite unique key on the combination of the CITY

and ST E

city varchar2(10),

Y KEY CONSTRAINTS

primary key constraint designates a column or combination of columns in the table's primary itions must be true:

re than one row in the table. (i.e. value must be unique)

ust not be a null)

primary key column cannot be of datatype LONG or LONG RAW.

EPTNO column: (column level Primary key constraint.)

REATE TABLE dept

mposite primary key on the combination of the ship_no and

ontainer_no columns of the ship_cont table: CREATE TABLE ship_cont

owner varchar2(20), constraint ship_cnt_pk PRIMARY KEY (ship_no, container_no));

********

Defining composite unique keys (Table leve

The following statement defines and en

AT column of the CENSUS table:

CRATE TABLE client (f_name varchar2(10),

l_name varchar2(10), address varchar2(10),

state varchar2(10), constraint client_unq UNIQUE (city, state)); PRIMAR

Akey. To satisfy a primary key constraint, both or the following cond NO primary key value can appear in mo

is part of the primary key can contain a null. (i.e. value mNo column that

A table can have only one primary key.

A

The following statement creates the DEPT table and defines and enables a primary key on the

D

C(deptno NUMBER(2) CONSTRAINT pk_dept PRIMARY KEY,

dname VARCHAR2(9), loc VARCHAR2(10));

The following statement defines a coc

(ship_no number(5), container_no char(7), status char(1),

*******

Page 99: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

98

create l (em ename varchar2(10), mg ber(4),

hiredate date, l

comm number(7,2), );

he constraint fk_deptno ensures that all employees in the emp table work in a department in the dept

HECK CONSTRAINTS

The CHECK constraint explicitly defines a condition. To satisfy the constraint, each row in the ondition either TRUE or unknown (due to a null). The condition of a CHECK

onstraint can refer to any column in the table, but it cannot refer to columns of other tables.

NV

Date consta

ND 99),

me

ON', 'NEWYORK', 'CHICAGO'))); Each constraint restricts the values of the column in which it is defined: CHECK_DEPTNO ensure that the no department number is less than 10 or greater than 99. CHECK_DNAME ensure that all department names are in uppercase. CHECK_LOC restricts department location to 'DALLAS' , 'BOSTON', 'NEWYORK', 'CHICAGO'

tab e emp pno number(4),

job varchar2(9), r num

sa number(7,2),

deptno CONSTRAINT fk_deptno REFERENCES (DEPTNO)Ttable. However, employees can have null department numbers. *************** C

table must make the cc

Note: CHECK constraint conditions cannot contain the following constructs: • Queries to refer to values in other rows

Calls to the functions SYSDATE, UID, USER, OR USERE•

• THE PSEUDOCOLUMNS currval, nextval, level, or rownum

• nts that are not fully specified.

The following statement creates the DEPT table and defines a CHECK constraint in each of the table's columns: CREATE TABLE dept

eptno number CONSTRAINT check_deptno(d CHECK (deptno BETWEEN 10 Adname varachar2(9) CONSTRAINT check_dna

CHECK (dname= UPPER (dname)), loc varchar2(10) CONSTRAINT check_loc CHECK (loc IN ('DALLAS' , 'BOST

Page 100: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

99

INSERT Statement

can be inserted into it. SQL allows the user to enter values in ERT.

blename(column list) VALUES(values list) Eg.

to the table emp1

emp1 VALUES (1001,'RAMU','MANAGER);

ent

>]}; Eg. :

o is 1001.

UPDATE emp1 SET ename='RAMAN' WHERE empno = 1001;

ELET ause is not specified all the r ble are deleted.

Syntaxle name [WHERE condition

Once a table is created, values

e table using the SQL statement INSth

Syntax : INSERT INTO ta

Inserting data in

INSERT INTO UPDATE Statem UPDATE is used to change the existing data of the table, UPDATE statement is used. Syntax: UPDATE <table name>

SET {column name >= <value expression>,….. {[WHERE <predicate

Change ename RAMU to RAMAN where his empn

D E Statement

DELETE statement removes one or more rows from a table. If WHERE clecords of the ta

: DELETE FROM tab ];

Alterin

sting table structure (adding columns / changing existing column structure)

use the ALTER TABLE statement to make modification to an existing table. The :

TABLE Details

Eg.: DELETE FROM emp WHERE empno = 1001; g a table

We can alter an exiusing SQL statement ALTER TABLE.

We canfollowing list outlines uses for the statement ALTER CLAUSE ADD clause To ADD a column to an existing table. Add the column to the end of the

table by default, or you can state a BEFORE clause and the column name before which you want the new column placed.

ptcode char(10) NOT NULL, EFORE mgrgrp);

ALTER TABLE department ADD (de B

Page 101: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

100

DROP clause To drop an existing column of a table. Give the DROP keyword with column name to be dropped. [when a column is dropped, all constraints associated with that column

the constraints dropped:

epartment STRAINT mgr_con;

are also dropped. Following are• Referential constraints • Check constraints • Single column constraints • Primary or unique key constraints • Multiple column constraints ] ALTER TABLE d DROP CON

MODIFY clause To change the data type of an exiting column, change the length of a value to allow nulls. When the data type is

ing column, the data in the table is automatically new data type.

T NOT NULL);

column, or change thechange in an existconverted to the

ALTER TABLE project MODIFY (department SMALLIN

ADD CONC

STlause

r existing column. When a unique constraint is defined, the column must contain only unique values.

RAINT To add a constraint to a new o

DROP CONSTRAINT To drop an existClause CONSTRAINT keyword with the co

the constraint name, you c

ing constraint. The statement uses the DROP nstraint name. If you do not know

an query the SYSCONSTRAINTS system table.

If you drop a constraint that has a foreign key relation, the referential constraint is also dropped.

MODIFY NEXT SIZE Clause

To change the size of the next extent. When a table is created, the EXTEN SIZE is included in the statement. This clause allows you to modify only the NEXT SIZ

T E value.

LOCK MODE Clause To change the locking mode of an existing table. The default at the time of the initial table creation is page-le

LE project

LOCK MODE (ROW);

vel locking.

ALTER TAB

When the ALTER TABLE statement, you can use more than one of the described clauses in a single statement. Also when altering a table with an associated view, be aware that the view may be come invalid.

Syntax: LTER le_name

{ADD/MODIFY} (column1 name datatype, column2 pe….);

Eg.: ADDING COLUMN DEPTNO to emp table

deptno number(4));

A TABLE tab

dataty

ALTER TABLE emp ADD (

Page 102: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

101

Syntax:

ALTER TABLE tablename ADD CONSTRAINT constraint_name (column constraint) Eg. : ALTER TABLE client ADD CONSTRAINT cl_pk PRIMARY KEY (NAME);

TRAINTS ON A TABLE

ISABLE CONSTRAINT constraint_name;

g.:

ENABL

Syntax

INT constraint_name;

DROPP NG C

yntax: name

DROP CONSTRAINT constraint_name; Eg. DROP CONSTRAINT cl_pk; DROP e can remove tables by executing the standard SQL command DROP TABLE. This command removes the entire table definition from database.

yntax:

Eg.

DISABLING EXISTING CONS

Syntax: ALTER TABLE table_name D E

ALTER TABLE client DISABLE CONSTRAINT cl_pk;

ING CONSTRAINTS OF A TABLE

: ALTER TABLE table_name

ENABLE CONSTRA Eg.:

ALTER TABLE client ENABLE CONSTRAINT cl_pk;

I ONSTRAINTS ON A TABLE

S ALTER TABLE table_

: ALTER TABLE client

TABLE

W

SDROP TABLE table_name;

DROP TABLE emp;

Page 103: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

102

ay by which the table can be got back. When table is ncerned freed table space may not be immediately used. To do so, use TRUNCATE

ommand for dropping a table.

S

at your application programs is processing or until your databa annot have referential constraints placed on any defined olumns not can any column of the table be referenced from another table. If the user has connect

e database, he can create a temporary table and build indexes on that temporary table.

Wh

The fol E STATEMENT.

E TABLE dep 2) CREATE TABLE department deptno char(3) not null, l, primary key (deptno, DEPTNAME)) space1 extent siz 3) CREA E project null,

Projname t null, department

prjstart date, prjend date, vendor varchar(50,10) )

ccount ( acctno integer,

subv FERENC 5) CREATE TEMP TABLE ( lnam fnam man H NO L

Once the table is dropped, there is no wdropped. The coc

TEMPORARY TABLE

Temporary tables last for the time thse is closed. A temporary table c

cprivileges on th

en creating your tables, the only elements that are necessary are a unique table name within the database and unique column names within each table.

lowing are the example of CREATE TABL 1) CREAT artment

deptno char(3) not null, deptname char(20 not null, mgrgrp char(10),

location char(15), primary key (deptno));

deptname char(20 not nul location char(15),

mgrgrp char(10),

in db e 24 next size 12;

TE TABL( projno char(8) not char(20) no char(20),

lock mode row; 4) CREATE TABLE a acct_type integer,

en varchar(50,20) RE ES project (vendor));

dba e char(20),

e char(20), ager char(20)) WIT OG;

Page 104: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

103

REATING VIEWS

A view is known as a synthetic table. We can perform query of update the view as if it is a table. We can of the

Control the insert and update data of the table.

he time of we enter CREATE VIEW statement, but if no column he referenced tables are used.

cessed. d on one or more tables, so it should always reflect he most current changes of the

bles.

The following example shows of two CREATE VIEW statements:

CREATE VIEW dept_view AS OM department where deptno = ‘ABC’;

way to control the data that users can access. The authorization can control who can rict users from accessing confidential data.

REATING INDEXES

We can create an index on one or more columns of the same table. At the time of the index

until the index build is complete. ith the create statement, you define an index name that is unique for that table.

statement

UN

CLUSTER option orders the table by the design of the index. You are al table.

EATE INDEX statement has additional keywords:

C

create the new view by using with definition based upon a current table or another view database

Views are created for many purposes: • Restrict users to specific rows or columns of tables.

• Avoid redundancy of data.

We can name each column at tames are specified, the names from tn

There are additional restrictions when using views. Because a view is not a real table, you cannot create an index, and the INTO TEMP, UNION, and ORDER BY functions cannot be proA view is baseta

SELECT * FR CREATE VIEW proj_view AS SELECT projno, projname FROM project;

A view is a modify the data and rest

C

creation, the database server puts an exclusive lock on the entire table W

Options of the create index

IQUE The UNIQUE option prevents duplicates from being inserted into the table.

CLUSTER The allowing only one CLUSTER index on a physic

Note

The CR

Page 105: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

104

• You use the DISTINCT keyword exactly as you the UNIQUE keyword. This option does not

index in ascending order. ASC is the default if not specified in

• The DESC keyword keeps the index in descending order.

CREAT N department (deptno);

AT

REATE INDEX proj_ix1 ON project (projno DESC);

LTERING INDEXES

There are only two reasons to use the statement; one is to change the CLUSTER option of an

existing reorder the data by the existing index. For the alter statement to work, the dex must have been previously created with the CREATE INDEX statement and you must have the

INDEX statement.

The CL

luster option of the index. When this is done, the table is ot affected. Any new inserts are placed randomly. Searches require a little more effort, but using this ption

Examp

CLUSTER;

CLUSTER

d pe ustered lustered index

allow duplicates in the table.

• The ASC keyword keeps hethe create statement.

The following are the examples of the CREATE INDEX statement:

E UNIQUE INDEX dep_ix1 O

CRE E CLUSTER INDEX c_dep_ix1 ON department (deptno);

C

A

index, and one is toinproper permissions to perform the ALTER

USTER option allows you to add clustering to an existing index.

To NOT CLUSTER option drops the c

no is still faster than a non-indexed table.

les of the ALTER INDEX are as follows:

ALTER INDEX dept_ix1 TO NOT ALTER INDEX proj_ix1 TO ;

r physical table. You must drop an existing cl

is alloweOnly one clustered indexew cindex if you want to add a n .

Page 106: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

105

9. DATABASE MANAGEMENT

he fol t functions.

• Updating • Deleting

uerying data

Using the EC our database. It is the most portant SQL st nt tatement does not modify data the database; y e a database table, a view, or the

ystem catalog ta es.

ou can e the SELECT statement in the following ways:

tement.

nced queries are

the simplest form of the S

le-list

ames, expression or aggregates. To select the entire column from a

isk (*).

r more table n

es;

DATA MANAGEMENT FUNCTIONS. T lowing are the types of data managemen

• Querying • Inserting

Q

SEL T statement is the primary way to query yT sim

inatemeou us

and can be the most complex. The SELECit only to query the data. You can select from

s bl

Y us

• Retrieve data from a database.

• Create new rows with the INSERT statement.

• Update data with the UPDATE sta

There are five SELECT statement clauses as follows:

• SELECT • FROM • WHERE• ORDER BY • INTO TEMP

Two additional clauses for more adva

• BY GROUP• HAVING

The SELECT statement

Let us first consider ELECT statement: SELECT select-list FROM tab

Where select-list : is a list of column n

table use an aster

table-list : is a list of one o ames. For example:

ous select * from h

Page 107: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

106

This statement will retrieve all the columns from the houses table and display their values for each row the h

only owner, adrs1, town columns data.

lected rows displayed one per page. Depending

[WITH NO LOG]]

he sim lest fo ition is:

n expression. An expression is a column name or a constant or any combination of ese connected by one of the arithmetic operators:

in ouses table.

select owner, adrs1, town from houses; This statement will retrieve

Note : selected rows displayed across the screen or se

pon the size of row data. u Full syntax of the SELECT statement. SELECT [DISTINCT] select-list

alias] FROM {table-name[table- [WHERE condition]

[GROUP BY column-list] [HAVING condition]

ESC]] [ORDER BY column-name [ASC | D

[INTO TEMP table-name COMPARISONS AND EXPRESSIONS T p rm of the comparison cond expr rel-op expr

expr is ath

+ Addition - Subtraction * Multiplication / Division

Following are all valid expressions:

wn

price * 1.15

price / no_bedrooms 2 * ((price + 1000) / no_bedrooms)

e in

king” / no_bedrooms

to“Working”

150000

today – 9

following ar valid town + 10 price / county “Wor

Page 108: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

107

rel-op is short for relation operator. This has nothing to do with relational database theory, but just o

= Equal

is ne of the following:

!= or <> not equal > greater than >= greater than or equal < less than <= less than or equal

AGGREGATE The following a 1. COUNT(*)

Thet the number of houses in the database with the bedrooms:

select count(*) from houses

2. COU

NULL values. If the column contains only NULLs, then zero is returned. For example ents there are, without referring to the agent table:

pr from rows that satisfy the WHERE m just the unique values in the column

the total number of bedrooms in the database, we

. AVG([DISTINCT] expr)

values in expr from rows that satisfy the WHERE clause, ws you to take an average of just the unique values in the

e per bedroom of houses in Working we could rite:

elect avg(prichouses

F IONS UNCT

ggregate functions are available:

COUNT(*) function returns the number of rows which satisfy the WHERE clause, including NULL values. For example, to coun

where no_bedrooms=3;

NT(DISTINCT col-name)

This function returns he number of unique values in column col-name from rows that satisfy the WHERE clause, excluding

, to count the number of different ag select count (distinct agent) from houses;

3. SUM([DISTINCT] expr)

The SUM function returns the sum of all values in exclause, excluding NULL values. DISTINCT allows you to su(the column has to be a numeric column.) To findcould write:

select sum(no_bedrooms) from houses;

4

AVG returns the average of all the excluding NULL values. Distinct allocolumn or expression. To find the average pricw s e/no_bedrooms) from

Page 109: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

108

where town = “Working” . MA (expr)

ue in expr from rows that satisfy the WHERE clause, ice of the most expensive house in the database,

select max(price) max_price ouses;

6. MIN

the WHERE clause, excluding the NULL values. To find the price of the cheapest house in Guildford we could write:

where town = “Guildford”; Notes

may only be used with columns, not with expressions. rd may only be used once within a select-list, either inside or

function, but not both. ggregate functions and non-aggregate expressions in a select–list

without using the GROUP BY clause. However you may have more than one aggregate,

ax(price), min(price)

from houses; (v) NULL values are handled as follows:

ntaining NULL re

Result if all NULL values

5 X

The MAX function returns the highest valexcluding NULL values. For example, to find the prusing a display label:

from h

(expr)

The MIN function returns the lowest value in expr from rows that satisfy

select min(price) from houses

(i) expr may not contain another aggregate function. (ii) The DISTINCT keyword(iii) The DISTINCT keywo

outside an aggregate(iv) You may not mix the a

e.g.

select m

Function Rows co

values aCount(*) COUNTED Number of rows COUNT(DISTINCT col) IGNORED 0 SUM(expr) IGNORED NULL AVG(expr) IGNORED NULL MAX(expr) IGNORED NULL MIN(expr) IGNORED NULL

You ca combination with the DISTINCT clause in the SELEC

he next set of functions is the time functions: DAY Integer that represents the day.

n use the COUNT, SUM, and AVG functions inT statement.

T

MONTH Integer that represents the month. WEEKDAY Integer that represents the d

represents Sunday). ay of the week (values 0 through 6,

where 0Y Four-digit integer tEAR hat represents the year. M Returns the date inDY mm/dd/yyyy format. DATE Returns a date value. EXTEND Adjust the precision of the DATE or DATETIME value.

Page 110: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

109

CURRENT Return a date/time value that represents the current date and time. THE WHERE CLAUSE

l clause of the SELECT statement is the WHERE clause. This fining which rows are retrieved from the database. For example:

Select * from emp where deptno = “10”;

This will retrieve all the employees information from the emp table who are working in the Dept No 10.

he syntax of the where clause is very simple:

Howev mplex, being a collection of one or more search conditions which may be ny particular ondition. The following query will select those 4-bedroomed houses, which are not in working:

in condition, or a subquery.

ORDER BY clause. You default, or in descending order of

select owner, adrs1, town from houses order by owner;

THE INTO TE

It is so save the result of a query in a temporary table, allowing the result to be ea ly rev bject of new queries. This may be achieved through the use of the INTO TE

INTO T

he temporary able c pears automatically when you exit INFORMIX-SQL.

The most important optiona

clause allows you to set conditions de

T WHERE condition

er, condition can be very coconnected by AND or OR. The operator NOT may also be used to negate a

c select owner, adrs1, price from houses where no_bedrooms = 4

and not town = “Working”; A search condition can be a comparison, a jo

THE ORDER BY CLAUSE

The output from your SELECT statement may be sorted by using the rticular column, which is themay sort in either ascending order of a pa

a column, by specifying the keyword DESC. For example:

This will sort the output of the query according to the owner column.

select adrs1, town, county from houses order by county, town; This will sort the output in town order within county

MP CLAUSE

m useful to be aetimes ble tosi iewed or to be the suMP clause:

EMP table-name [WITH NO LOG]

T t reated disap

Page 111: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

110

select town, avg(price) avg_price

you are using an INTO TEMP clause. ii) Though by definition, a relational table does not contain duplicate rows, a table created with the

O TEMP clause may do. ii) OG clause to suppress all transaction logging for the

ANGE LUE LISTS, NULLS

extended to include a range search:

D expr

A value list search:

and a s

las

NOT keyword is optional.

Consider some select adrs1, town, county, price This query retrieve information on houses

plus 15%is between the range 150000.

from houses group by town into temp temp1; By selecting all values from the temporary table temp1. Note i) You may not use an ORDER BY clause if (

(INT

(i You may use the optional WITH NO Ltemporary table.

R S, VA

The comparison condition can be

expr [NOT] BETWEEN expr AN

expr [NOT] IN (value-list)

pecific search for a NULL value:

column-name IS [NOT] NULL

This t comparison is the only way to specifically search for a NULL. In all these conditions the

examples of the above:

from houses where price *1.15 between 100000 and 150000;

whose price100000 and

select owner, adrs1, town from

This query retrieve information on houses whose book_date column is outside the

ry-June 1990. houses where book_date not between “1/1/90” and “30/6/90”;

range Janua

select price, adrs1, town, no_bedrooms This query selects in from w

formation on houses in houses here town in (“Guildford”, “Working”)

order by town, price;

both expression, ordering the display by price within town.

select adrs1,agent, book_date This query retrieves h from houses

ouses where the price column is NULL.

where price is null;

Page 112: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

111

S

tring matching No set ison.

column-name [NOT] MATCHES “string”

nction following wildcard characters are use:

ters

of comparison conditions would be complete without some form of string matching compar

column-name [NOT] LIKE “string”

for above both the string matching fu

LIKE % Matches zero or more charac _ Matches any one character. MATCHES * Matches zero or more characters (as % in LIKE) ? Matches any one character (as _ in LIKE) […] Matches any one of the enclosed characters. [a-z] Matches any character in the range specified. [^…] Matches any character not in the brackets. \ Nullifies any special significance of the next character (ex. As

given below)

ex. me [NOT] LIKE “string” [ESCAPE “escape-character”]

ed to escape the significance of the % character, returning e stud

from houses owner matches “A*”;

Retrieves all rows with an owner starting with A.

where expression matches “(x+y)\*2z”

column-na

column-name [NOT] MATCHES “string” [ESCAPE “escape-character”]

select student_id, score from scores where mark like “8_\%” escape”\”;

Here the backslash character has been usth ent id’s of student with exam marks between 80% and 89%.

select owner, adrs1, town whereselect owner, adrs1, town

where owner matches “[A-M]*”;

Retrieves all rows whose owner starts with y letter in the range A-M. from houses an

sele t o from houses either X, Y or Z.

c wner, adrs1, town Retrieve all rows whose owner starts with

where owner matches “[XYZ]*”; s d wn, county, price elect a rs1, to

s “Working”;

Retrieve houses in Working whose price is between 100000 and 130000. from house

where price between 100000 and 130000 and town =

sele t m houses ere no_bedrooms = 4

(t town = “Guildford”);

Retrieve all houses with 4 bedrooms and not in either Working or Guildford.

ct adts1, town, agen fro wh

and not own = “Working” or

select adrs1, to from houses where no_bedro and not town = “ orkin or town = “Guildford”;

Retrieve all houses with 4 bedrooms and n Working, plus all houses in

less of the number of

(difference in both is only parentheses)

wn, agent

o Guildford, regardrooms.

ms = 4not i

W g” bed

Page 113: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

112

CONDITIONS

number of roworresponding house.

uery is like this s1, town, bedroom_size, bedroom_no

Consider the two tables houses and bedrooms. For each row in the houses table there are a s in the bedrooms table, one row for each bedroom. We would like to display the

rows in the bedrooms table for a particularc

Then the qselect adr

from houses, bedrooms where houses.ref_no = bedrooms.ref_no;

A table alias is to a table what a display label is to a column. It gives us a shorthand name for a table which we can use in other

parts of the query.

select adrs1, town, bedroom_size, bedroom_no s h, bedrooms b

wh

select a.agent, h.adrs1, bedroom_size, bedroom_no

where h.ref_no = b.ref_no; and a h.agent and h.pric

SUBQUERIES

Suppose we want to find the most expensive house in our database that means there are two select statements has to be used to get the result as follows

Query 1 : select max(price) from houses; Query 2 : select adrs1, town from houses where price = (result of query 1);

Then the query is written as one statement, where the query inside the parentheses is known as

a subquery:

select adrs1, town from houses where price = (select max(price) from houses);

In above example the subquery is returning only one value, if the subquery is returning more

than one value then in where clause by use of the keywords ANY or ALL, and a comparison operator (such as =,>,etc.).

from house ere h.ref_no = b.ref_no; from agents a, houses h, bedrooms b where h.ref_no = b.ref_no;

select a.agent, h.adrs1, bedroom_size, b.bedroom_no from agents a, houses h, bedrooms b

.agent =e between 100000 and 120000;

Page 114: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

113

select adr

from houses where price > any

ll the houses whose price is greater than any houses (i.e. the lowest

from houses

from houses

If you use ALL instead of ANY, the query will select rows in which price is greater than all the

OR

eater than the highest price in Working.

among) ng with the same owner’s

where town = “Guildford”);

ries as follows:

-op {ALL| ANY} (SELECT statement)

T] IN (SELECT-statement)

ted when the subquery is true (or false if NOT is used).

where price > (select avg(price) from houses h where x.town = h.town);

s1, town, price (select price from houses where town = “Working”);

The above query finds arice) in working. p

select adrs1, town, price

where price >all lect price (se

where town = “working”);

values returned by the subquery.

It will select houses with prices gr

We can use the Keywords like IN or NOT IN to select rows having values among (or not

those returned by the subquery. The following query selects houses in Workiname as houses in Guildford;

select owner, adrs1, town from houses where town = “Working” and owner in (select owner from houses subquery conditions may be summa WHERE expr rel WHERE expr [NO Our main query is execu

select adrs1, town, price from houses x

Page 115: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

114

select a. agent, a.adrs1

(select h.agent houses h

urn a value return a value for each row, unless you therefore invalid:

ps of rows so that the rows in each group have n may then be applied to the rows in each group:

uses

from agents a where not exists

from where a.agent = h.agent);

THE GROUP BY CLAUSE

Within the same SELECT statement you may not mix aggregate functions (which retfor a number of rows) with column names or other items that

e following isuse either a subquery or a GROUP BY clause. Th select town, avg(price)

from houses;

The GROUP BY clause divides a table into grouhe same value in a specified column. A group unctiot

select town, avg(price)

from ho group by town;

(calculating avg price town w

ise)

GROUP BY town

Hindhead AVG(price) = x Guildford AVG(price) = y Working AVG(price) = z

First the rows are grouped according to the column named in the GROUP BY clause, then the

unction (AVG) is applied to the different groups in turn, with this result:

avg_price

group f

town

108900.00 100002.50 108900.00 117916.67

Hindhead Guildford Working New Malden

e column, as in:

ms, avg(price) avg_price

group by town, no_bedrooms order by town, no_bedrooms;

You may group by more than on

select town, no_bedroo from houses

Page 116: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

115

you may use more than one aggregate function, as and in:

from houses town;

Group BY an expression which appears in the select-list, you may use an esenting that expression’s position in the select-list, as in:

no_bedrooms/no_baths, avg(price) houses

p by town,2 rby 1,2; Y clause is present, it must be the last clause in the statement.

HAVING CLAUSE

Just as the WHERE clause imposes conditions as to which individual rows are selected, the e imposes conditions as to which groups are selected:

) where the total value of houses in the nd number of houses in each selected

, avg(price) avg_price, count(*) no_houses houses

> 250000 2;

s ust be based on a

d on comparisons with other groups, you may include a subquery in the HAVING clause. The following query selects group (towns) whose average

ildford: rice) avg_price

from houses

(select avg(price)

where town = “Guildford”)

select town, min(price), max(price) group by

NOTES

(i) If you need tointeger repr

select town, from grou orde

(ii) If ORDER B

HET

HAVING claus HAVING condition

The following query will only select those groups (towns. It will display the average price atown is greater than 250,000

town:

select town from group by town having sum(price) order by

oteN(i) Since the HAVING clause is for selecting groups, the condition m

group or aggregate function.

(ii) To select groups base

houses price is less than that of houses in Guselect town, avg(p

group by town having avg(price) <

from houses

order by 2;

Page 117: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

116

THE UNION OPERATOR

e situation where we have two tables of the same format and we need to combine able with the data from the other to from a third table, or possibly just to display the

sults. The UNION operator allows us to do this by combining two or more SELECT statements into a single q

e from houses1

union

Notes:

(ii) orresponding

(iii) use an ORDER BY clause in the last SELECT statement but it must refer to an

(iv) UNION operators may not occur inside a subquery and may not be used in the definition

(v) st SELECT

INSERT, UPDATE and DELETE Statements

Adds one or more rows to a table:

tement}

rms of the INSERT statement. The first is where you specify the VALUES

wn,

Consider ththe data from one tre

uery. SELECT –statement UNION [ALL] SELECT – statement [UNION[ALL]select –statement….] Example

select adrs1, town, county, pric

select adrs1, town, county, price from houses2 into temp shorthouses;

(i) The keyword ALL may be used to leave duplicates.

The number of items in the select list of each query must be the same c

items in each query must have identical data types.

You may

item by integer, not by identifier.

of a view.

The column names of the resulting table are the same as those from the fir

statement, which may be display labels.

INSERT INSERT INTO table-name [(col-list)] {VALUES (value-list) | SELECT sta

There are two main fo

keyword and a list of values to be inserted into a row, for example:

insert into houses (ref_no, owner, adrs1, adrs2, tocounty, no_bedrooms)

values (0, “Thomas”,”9, The Street”, null, “Bagshot”, “Surrey”, 4)

Page 118: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

117

The second is where the values are to be taken from another table in the database in the

ccording to the SELECT statement spedatabase a cified, for example:

= “Working”; er specify a list of column names to contain the values, the being set

NULL

otes

ing inserted, a zero must be used as the value. This will be

ATE table-name SET col-name = expr[….] [WHERE condition]

UPDATE table-name {(column-list | * = (expr-list)

Example :

update

t

(i)

s set price = (select avg(price) from houses) where price is null;

insert into temph select * from houses

where town In either case you may eith

to , or the list may be omitted in which case a value must be specified for every column in the row (the keyword NULL may be used as a value).

N

(i) The keyword NULL may be used to inset a NULL value in particular column.

(ii) If a serial column is be

replaced with the next appropriate serial value when the row is added.

UPDATE Modifies data in one or more rows of a table:

UPD

[WHERE condition]

houses set price = price * 1.10;

This increase the prices of all the houses by 10% that means total value multiplied by 1.10

update houses (county, notes) = (“Surrey”, “Modified”) where town = “Guildford”;

This changes all the county columns to Surrey, if the town column is Guildford, and sets the notes

column to Modified.

No es:

expr may be a SELECT statement subquery, returning a single value and enclosed in

parentheses, e.g.

update house

Page 119: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

118

(ii) You may not update a SERIAL column.

ns, all statements within a BEGIN/COMMIT WORK block

amp

o dele

lts to a printer, file, or a pipe.

bles in database. file.

Exit from the SQL command screen.

(iii) For database with transactioare treated as a single transaction. All the rows affected by an UPDATE will thus be locked for the duration of the transaction.

DELETE Deletes one or more rows from a table: DELETE FROM table-name [WHERE condition] Ex le:

T te all the houses costing price less than 100,000 from houses table:

delete from houses where price < 100000; SQL New entering new SQL statements.

Run run the current SQL statement. Modify modify the current SQL statement Use-editor use the vi editor.

Output run & send query resuChoose choose a command file as the current SQL statements. Save Save the current SQL statements in a command file. Info Information about the taDrop delete a SQL command Exit

Page 120: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

119

10. WORKING WITH FORMS

elete data from one or more tables. Forms re use to do record basis. It is just like a screen builder in other packages.

Menu will be displayed as

Creating Default form

dd, modify, view and dA Form is a screen use to Ad operation on record bya

Steps for creating default Form

. Typ isql a1 e t the Unix prompt then it open the Informix SQL and the mainfollows.

INFORMIX-SQL: Form Report Query-Language User-menu Database Table Exit Run, Modify, Create, or Drop a form.

k option then the following screen will be2. Clic Form displayed FORM: Run Modify Generate New Compile Drop Exit Use a form to enter data or query a database. 3. Select Generate option and the type the name of the Form and press Enter key.

Select the Table name and press Enter key . It d as follows . Select Table-Selection-Complete then SQL creates a default form with the selected tables.

4. 5 isplays another screen6 GENERATE FORM: Table-selection-complete Select-more-tables Exit Continue creating a default form with the selected tables.

L-W for Help -------- ----------------------- eva@tvr --------------- Press CTR

elect the 7. S Run option and again select the created Form to Run it. Then the Form will be isplayed with default layout as follows d

PERFORM: Query Next Previous View Add Update Remove Table Screen ... Searches the active database table. ** 1: emp table** pno [ ] ename [ ] desig [ ] deptno [ ] b_pay [ ] da [ ] hra [ ] deduct [ ] gross [ ] net [ ] Now we can do required operations, Add, View, Update, Query, Remove Etc.

Page 121: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

120

MODIFYING THE FORMS

You can modify the already existing forms by 1. Select Form menu

INFORMIX-SQL: Form Report Query-Language User-menu Database Table Exit Run, Modify, Create, or Drop a form.

. Press enter key on Form command option then the follo2

wing screen will be displayed

FORM: Run Modify Generate New Compile p Exit Use a form to enter data or query a database.

. When you Press en3 ter key on Modify command then Select the name of the form from the list & Press E

. The following code will be appear in the Vi Editor

ataba mk tvr creen size 24 by 80

p_no [f000 e_name [f001 design [f002 ] dept_no [a0] b_pay [f003 da [f004 ] hra

deduct [f007 ] net_pay [f008 }

nd tables

ttributes

01 = emp_date_vs.e_name;

03 = emp_date_vs.b_pay; a;

s.deduct; 08 = emp_date_vs.net_pay;

nd

nter key to move into Vi Editor 4 d se rti @s{

] ]

]

[f005 ] grosspay [f006 ]

]

e

emp_date_vs af000 = emp_date_vs.p_no; f0f002 = emp_date_vs.design; a0 = emp_date_vs.dept_no; f0f004 = emp_date_vs.df005 = emp_date_vs.hra; f006 = emp_date_vs.grosspay; f007 = emp_date_vf0e

Page 122: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

121

1. If you wish to add/ Modify form by using the various attributes available with the Form designing like add

atabase rtimk@tvr

ize 24 by 80

p_n

des 02 ]

b_pa [f004 ]

] ]

deduct

nd

ttribut s = “Please don’t enter null value”;

01 = emp_date_vs.e_name;

0 = emp_date_vs.dept_no; f003 =

05 = emp_date_vs.hra; grosspay; deduct;

f008 =

. After adding / modifying forms with various attributes , save & exit from vi editor

ed

MODIFY FORM: Compile Save-and-exit Discard-and-exit Compil

. Compile the form & then make sure it is free from errors then click Save-and-exit to return to

nerate New Compile Drop Exit

of attributes you applied for the fields.

ing comments, picture, default as shown below. d screen s{

o [f000 ] e_name [f001 ]

ign [f0dept_no [a0]

ay [f003 ] dhra [f005

rosspay [f006 g [f007 ]

net_pay [f008 ] } e tables emp_date_vs a esf000 = emp_date_vs.p_no , commentf0f002 = emp_date_vs.design, include=(“cm-i”,”cm-ii”,”af”,”jwm”); a

emp_date_vs.b_pay; default=5000; f004 = emp_date_vs.da; f0f006 = emp_date_vs.

07 = emp_date_vs.f0emp_date_vs.net_pay;

end 2 3. The following menu is display

e the form specification. 4

FORM menu & then select Run command. FORM: Run Modify Ge Now you can see the form with various effects

Page 123: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

122

11. ACE REPORT WRITER

TRODUCTION

enerator which combines the interrogating the database with powerful report formatting capabilities. It allows you

from several tables in a database, add page and column headings, group and he report on the screen or printer, or save it in a file. Reports can be anything

rom ph

can be obtain by selecting the Report option from the SQL menu. These menu: Run eport screen from which a previously created report may be run by

list displayed. Just move the cursor to the desired report name and

ystem editor.

reates a default report. This option is covered in detail in next

tes a new report specification from scratch, using the system editor.

eport that may be run. Drop ort (deletes), selected from the list displayed, from the database. Exit e INFORMIX-SQL main menu.

REATING THE DEFAULT REPORT

main menu, giving you access to the REPORT menu. . Select the option from the REPORT menu

c. Sel. Type the report a name

Informix-SQL will generates the report default report specification and displays as follows The report specification was successfully compiled. g. You may n option and run your report. It will be displayed on the screen, since

this is the dh. The output from this default report will appear on the screen.

IN

extension of the SQL Report Files. ACE is a report g. ACE is thefacilities of SQL forto combine information subtotal data and print tf one directories to mailing labels, standard letters to resource schedules. In this module we will see how to create and customize a variety of reports, taking the data from our emp database.

VOKING ACE REPORT WRITER IN Report menu

are the options REPORT

Displaying the Run Rit from the selecting

press RETURN. Modify This option is use to modify the text of a report specification file using the s

The report specification file must be compiled before the report can be run. Generate The generate option

section. c

New Crea Compile The compile option compiles a report specification file into a r

Drops a rep

Returns to th

CTo create a default report specification, follow these steps: a. Select Report from the SQL b Generate

ect a Database name if no database is open de. Select the table name for the report. f.

ow select the Runefault.

Page 124: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

123

Notes If you choose the New option on the menu, INFORMIX-SQL calls your system editor and

create a report specification from scratch. However it is much easier to use the Generate option, followed by Modify.

isation. There are two files associated with a report: a source file with the extension .ace (or .ACE

om one table without any formatting, arithmetic, s, you must customise your default report using an

ort specification involves adding more instruction into the mandatory sections, ional sections.

ollow these steps to customise a default or previously created report specification:

. Select Modify

allows you to

Using the Generate option, you only specify one table to be used in the report, but more tables may be included during custom

on DOS), and a compiled, runnable file with the extension .arc (or .ARC on DOS).

CUSTOMISING ACE REPORTS

A default report produces all the information frtotaling or run time user input. To add these featureeditor.

Customising a repand adding certain opt

F

1 option from the REPORT menu. You are presented with the MODIFY REPORT

me select a report from the list displayed, using the arrow keys followed by RETURN, or type in the name in full. This will call up the editor specified in the DBEDIT

r.

Ma t and save the file.

DIFY REPORT menu, from which you should select

. If y , the message essful will be displayed. Go to Step 6.

5. If the compilation was unsuccessful and the report contained errors, you are presented with, and sho the Correct option from the COMPILE REPORT menu. Your editor is called again and

errors in your specification are highlighted with error messages. Correct the errors, save your file and return to Step 3. Note that ACE often points to the line after where the error really occurred.

. When the compilation is successful, select the Save-and-exit option from the MODIFY REPORT me

un Note: Comments may be included anywhere within a report by either enclosing them in curly

ceding them with a double dash (--). Do not use a hash (#) to precede them since this kind of comment line is used by ACE to denote an error and is removed

nu, from which you may

environment variable or your system editor (such as vi). Then the report will be opened in the vi edito

2. ke the changes required to customise your repor 3. You are then presented with the second MO

Compile.

4 our report specification has compiled correctlyReport compilation succ

uld select the

6

nu. 7. R /execute the report by selecting the Run option from the Menu.

brackets { }, by pre

during compilation.

Page 125: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

124

ired and three are ptional. The order in which the sections my appear is a set out opposite, and they are covered in detail

n.

ired. The database section identifies the database on which the report is to

used in the report and also any

command line parameters.

mpt the user at run time for parameters from the keyword.

UTPUT Optional. Controls the overall page format, such as length and width, and also

ELECT Required. The SELECT section contains one or more SQL SELECT statements which mns and rows on which the report is to based.

READ

termines the final appearance of data in the report. There follows an example of a fully customised report specification: Example 1. : R database prop define

variable maxprice money

ter maximum price:" end

t top margin 0 bottom margin 0

nd

h.town htown, aent, price

where price <= $maxprice order by agent, price

REPORT SPECIFICATION STRUCTURE

The report specification file has up to six sections of which three are requoin the following sectio

DATABASE Requ

operate.

DEFINE Optional. This section is used to declare variables

INPUT Optional. Used to pro O

redirection of the output to a file, printer or a pipe. S

specify the colu

The SELECT section may be placed by a READ section, which allows you to retrieve data from an ASCII file instead of from a database.

FORMAT Required. The FORMAT section de

eport Specifications

erty end

end input

prompt for maxprice using "en

outpu page length 23 e select h.adr1 hadrs1, from houses h end

Page 126: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

125

format

first page header print hadrs1 clipped, ", ", htown clipped; sing "$,$$,$$,$$$"; print 3 spaces, agent

need 3 lines print col 5, "total for ", agent, " = ", group count using "<<<&"

skip 1 line N> to continue" end

ote : Reports may be run directly from the command line by using the ACEGO program via the acego ollows

xample No.2 :

ION */

/* DEFINE SECTION */ er

/* OUTPUT SECTION */ page

elect STATEMENT SECTION */ pn

ename, desig, deptno, b_pay, da, hra, deduct, gross, net

nd

format firs p t pr t

print print column 2, "-------------------------------------------------------"

print column 35, price u

after group of agent

skip 1 line

skip 2 lines

page trailer

pause "Press <RETUR

Ncommand or the isql command as f

sacego -s reportname or isql -s -rr reportname E

database deva@tvr end /* DATABASE SECT

efine d variable dep integend output length 22 end

s /* SELECTo,

from emp e

/* FORMAT SECTION */

t page header rin "OFMK" in "----"

column 2, "Emp Name Per.No Desig Dept No. Basic Pay "

Page 127: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

126

page header print column 2, "Emp Name Per.No Desig Dept No. Basic Pay " print co

he report will

DATABASE database-name END database deva@tvr 0000 end

you may specify the key ASCII stead of the name of a database, as in: database ASCII end

ers wh

xa

Variable count1 type integer Variable newdate type date

20)

y subsequently be assigned values using T statement for example:

e s follows

own name are enter on the command line: Define type integer pe char(10) End

Select * from houses

lumn 2, "-------------------------------------------------------"

The DATABASE Section

This section must be the first and contains the name of the database from which tbe generated. The syntax is

Example:

If you are using a READ section instead of SELECT section, in

The DEFINE Section

The DEFINE section may be used to declare variables which can be used in the report, and paramet ich can accept values from the command line. The VARIABLE statement: - The syntax of VARIABLE statement is:

VARIABLE var-name datatype Here is an e mple of a DEFINE section with some variable statements:

Define

Variable string1 type char(End

The variables are initially set to zero or space and mathe LE

Let count1 = count1 + 1 Let string1 = "New Text String"

Some time variable value may be taken from command line in this situation we must use th

PARAM statement a

PARAM[integer] var-name data type Suppose to print the report of details of houses which are under a certain price and are in a particular town. The price limit and t

eParam[1] maxpric

Param[2] reqtown ty

Where price <= $maxprice and town = $reqtown end

Page 128: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

127

This report may then be invoked with a command line such as the following, which reports on

0:

Guildford

ts may not be run from the REPORT menu, only from the nu).

variables may be declared in an ACE report using the VARIABLE and PARAM statements.

If a variable is to be used in a SELECT statement, then the variable name must be preceded by a

d to specify the field names and data types of the records in an ASCII i been specified in a READ section. The syntax is as follows: type [,…]

or Example: (25), address1 char(25),

town char(25), no_beds smallint, price money,

otes: A MONEY data type must be specified simply as MONEY.

ince t II file and not from the database, the field names specified hose in any table, even if the data was unloaded from that table.

The IN

pted for at the start of the report using an INPUT section. Note the position in a report specification of the optional INPUT section: DATABASE se [DEFINE secti [INPUT section

There is only one type of statement that may appear in an INPUT statement- the PROMPT

tax of which is as follows:

For example: Vriable end_date date

End Input

houses in Guildford which cost less than $110,00 sacego -s proprep1 110000Notes: • A report which uses PARAM statemen

command line (or from User-me• A total of 100

•dollar sign ($), as in the example above.

The ASCII statement

The ASCII statement is usenput file, when one has

ASCII field-name data-

F ASCII name char

agent char(25) N

S he data is coming from an ASCneed have no correspondence to t

PUT Section

Variables which have been declared in the DEFINE section may be prom

ction on] ]

statement, the syn PROMPT FOR var-name USING "string"

Define Variable start_date date

Page 129: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

128

rt_date using "Houses booked after:" Prompt Select * from houses

Where bookdate > $start_date and bookdate < $end_date end

The OU

assumes

eral

changed in the OUTPUT section by a combination of any of the following tatem

ger REPORT TO { " IPE "program-name" |PRINTER }

For example the following ou ort to the screen: Output

length 22

Note th tion in a report specification:

E section ection]

he REPORT

he output from d either to a file, to o another command via a pipe using the REPORT TO statement,

which has the followin

REPORT TO { "file-na

TPUT section will save the output from the report i report:

Report to "report" end

Prompt for sta for end_date using " but before:"

TPUT Section

The original output section allows you to set page dimensions for the report and also to directthe output to a file, the printer or, on UNIX systems via, a pipe to another program. ACEev default values for page dimensions. s

hese defaults may beT

s ents:

LEFT MARGIN integer RIGHT MARGIN integer TOP MARGIN integer BOTTOM MARGIN integer PAGE LENGTH inte

file-name" |P

tput section works well when sending a rep

Page

Left margin 0

Bottom margin 0 end

e position of the OUTPUT sec

DATABASDEFINE s[

[INPUT section] [OUTPUT section]

T TO statement

the report appears by default on the screen, but it may be redirecteTthe printer or, on UNIX systems, t

g syntax:

me" |PIPE "program-name" |PRINTER }

This OU n a file named

output Page length 22 Left margin 0 Bottom margin 0

Page 130: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

129

If you use the statement

EPOR

There is no way of pa ort at run time, but a choice of printers may

be effected by use of a UNIX O PIPE statement. The shell script, which e shall call acepr, takes the following form:

script to accept input from a pipeline and send it to lp, but asking for the printer destination

irst.

lp -d${D

to pipe "asepr"

his sc

reen, file or printer. (F)ile or (P)rinter? \c"

ad $d

name-> \c"

he SE

section is mandatory in a report specification, since it determines which ed for the report.

R T TO PRINTER

The report will be directed to the program named in the DBPRINT environment variable. If this is not set, then ACE will use lp on UNIX systems.

ssing a printer name to the rep shell script and the REPORT T

w

#### f

#echo "Which printer? \c" read DEST < /dev/tty

EST} The OUTPUT section would then contain the line: Report T ript may easily be extended to give the user a choice of redirecting the output to screen, file or printer:

script to accept input from a pipeline and send ## it to a choice of sc

cho "Output to (S)creen,ere est < /dev/tty case $dest in s|S) cat > /dev/tty ;;

f|F) echo "Enter file read file < /dev/tty cat > $file ;; p|P) lp;;

esac

OTES : N (i) The RIGHT MARGIN statement is only effective when the FORMAT section consists (ii) The PAGE LENGTH setting includes the TOP MARGIN and BOTTOM MARGIN. (iii) The TOP MARGIN appears above any page header, and the BOTTOM MARGIN below any

page trailer.

LECT or READ Section T

The SELECT or READ data is retriev

Page 131: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

130

The SELECT section may be replaced by a READ SECTION, which allows you to take the data from an SCII a database.

e to the other section as follows:

DATABASE se[DEFIN

UTPUT section] ELECT or READ section

A SELECT section starts with the keyword SELECT which also introduces the first SELECT tatement. The section must still end with the END keyword, as in

Select owner, adrs1, town, price From houses End

T statements have the same form as in SQL, but with certain conditions, overe

Where me, they can normally be distinguished from each oth r in ACE, apart from in the select-list of

e SELECT statemen lay label must be defined, the display label an the

F

bel may also be used to ORDER BY an expression, instead of using an integer. Example: Select a.agent agent, a.a

.town agent, h.adrs1

f agagent

end

ote the follow :

A file instead of from The SELECT or READ section is positioned relativ

ction E section]

[OS

s

In ACE, SELECc d in the following sections. Non-unique column names

two columns in different tables have the same naer by us ruct. Howevee of the table column const

t, this is not valid and instead a dispthc n be used in any of the following clauses:

ORDER BY GROUP BY AFTER GROUP OF

EFORE GROUP OBPRINT statement

A display la

drs1, hadrs1, htown htown a

from agent a, outer houses h where a. agent = h.agent order by agagent, htown

end format before group o

print agagent, agadrs1, agtown print on every row rint column 10, hadrs1, htown p

N ing points about this example

Page 132: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

131

e no associated houses rows:

h

2. Dis town columns of agents and houses:

nt, a.adrs1 agadrs1, a.town agtown, h.adrs1 hadrs1, h.town h.town

3. These disp e ORDER BY clause and PRINT statements:

order b a.age print agent, agadrs1, agtown

ariables in SELECT statements

d in SELECT statements, but they must be preceded by a dollar

qtown char(20)

pt for reqtown using "Enter required town: "

drooms, price

e town = $reqtown end

MULTIPLE SELECT STATEMENT If there is more than one SELECT statement, the following conditions must be borne in mind:

• A semicolon must be used to separate each statement from the next. • All but the last statement must have an INTO TEMP clause. • Only the last statement may contain an ORDER BY clause. • You may find that a UNION clause suits your needs better, particularly if you need to read the

same table twice.

1. Table aliases a and h have been defined for the tables agent and houses, and an outer join which will return rows of the agent table which hav

from agent a, outer houses

play aliases agent, agadrs1, agtown, hadrs1, and htown have been defined for the agent, adrs1, and

select a.agent agage

lay aliases have then been used in th

y nt, h.town

print column 10, hadrs1, htown

V

ACE variables may be usesign($) to distinguish them form column names. For example, the following report fragment shows how the variable reqtown could be used in a SELECT section to give information on the houses in a particular town: define

le re variab end input

prom end

e select owner, adrs1, no_b houses from

wher

Page 133: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

132

The READ section

This section m y optionally re in an ACE report specification, and o retrieve ta from an ASCII file, such as an UNLOAD file, instead of from a database. By field delimiter is taken to be the vertical bar (|), or whatever is in the environment variable

DBDELIMITER. This may be overridden by specifying a delimiter in the READ statement.

The

ilename" [DELIMITER "symbol"]

F S n quotes, that separates the fields in the ASCII file,

ER environment variable.

ed.

in the ASCII statement of the DEFINE section, that is used as a sorting key.

Notes (i) specify an existing database in the

(ii) Use an ORDER EXTERNAL BY clause to specify the ordering where the file is already sorted

FORMAT section

FORMAT section

ada

place the SELECT section allows you tdefault, the

syntax of the READ statement is as follows:

READ "f ORDER [EXTERNAL] BY field-name [ASC|DESC] [,…]

ilename is the pathname of the ASCII file, enclosed in quotes.

ymbol is the delimiter character, enclosed iand overrides that in the DBDELIMIT

External is an optional keyword indicating that the records in the ASCII file are already sort

field-name is the name of a field, as defined

For example:

Read "/usr/db/agents.unl" Order by company End

If you are using an ORDER BY clause, you shouldDATABASE section, rather the ASCII keyword.

and you wish to use AFTER or BEFORE GROUP OF control blocks on two or more fields.

The format section is mandatory and consists of one or more control blocks, each consisting of

one or more statements. Note the position of the FORMAT section relative to the other section in an ACE report specification:

DATABASE section [DEFINE section] [INPUT section] [OUTPUT section] SELECT or READ section

There is a special, default control block called EVERY ROW, which excludes all other control

blocks and does not allow any statements. However, the layout of a non-default section is as follows:

Page 134: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

133

statement(s)

end

The FORMAT Section of Report consist of the following control blocks

EADER 2. PAGE HEADER

4. ON LAST ROW

FIRST PAGE HEADER

a

Ex. : first page header

taken before rows are read from the database. The u k is to print information on the first page of a report, but is may also be s lar d earlier in the DEFINE section. For example:

first page header

print land;

PAGE HEA The be displayed on top of every page as a page header.

The PAGE HEADER control block specifies what processing is to be done at the top of each page of the report. It can be used to print column headings, using the PAGENO expression, the page number. It may also be used to initialize variables at the top of each page. For example:

format control block 1 statement(s) …… control block 2

……

CONTROL BLOCKS IN FORMAT SECTION

1. FIRST PAGE H

3. ON EVERY ROW

5. PAGE TRAILER

The data put in the FIRST PAGE HEADER will be printed on the first page to a report, as Report Header

print "REPORT NUMBER 1" skip to top of page

The control block defines the action to thesual use for this control blocued to initialize variables dec e

let land = ascii 27, "&k2s" let norm = ascii 27, "&kos"

print column 40, "Housing Report 2" print column 40, "-----------------------"

DER

data put in this block will

Page 135: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

134

Page header Print column 70, "Page ", pageno using "<<" Print column 6, "ADDRESS", column 25, "PRICE", COLUMN 40, "agent"

Notes: (i) A PAGE HEADER control block is overridden by a FIRST PAGE HEADER control block. To get

the same page heading at the top of each page including the first, you must duplicate the headings in the PAGE HEADER and FIRST PAGE HEADER blocks.

(ii) You cannot use the PRINT FILE statement in a PAGE HEADER CONTROL BLOCK. ON EVERY ROW

The ON EVERY ROW tells Ace when to print the columns, in this case one line for each row returned. That means one record for one line from the selected table.

The ON EVERY ROW control block specifies the action to be taken on each row retrieved by the SELECT section. This block is used to format the detail rows of a report and is where most of the work of the report is done.

On every row Print hadrs1 cl wn clipped; Print column 25, price using "$,$$$,$$$"; Print 3 spaces, a

Notes (i) If a change in column value triggers a BEFORE GROUP OF control block, it will be executed

before the ON EVERY ROW block. (i column value triggers an AFTER GROUP OF control block, it will be execute after

e ON EVERY ROW block. ON LA T ROW

he data put in the FIRST PAGE HEADER will be printed on the first page to a report, as a Report Header

This block specifies the actions to be taken after the last row is returned by the SELECT section. It is most often used to display grand totals. For example:

On last row

Print "Total of agents = ", count of agents Print "total of houses = ", count of houses Print Print column 30, "end of Report"

Notes (i) he statements in the ON LAST ROW are executed after those in the ON EVERY ROW and

FTER GROUP OF control blocks. (ii)

ipped, "," hto

gent

i) If a change inth

S T

TA

The values from the last row processed are available for use in an ON LAST ROW block.

Page 136: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

135

PAGE TRAILER The data put in this block will be displayed on bootom of every page as a page Footer.

hat information will appear at the bottom of each page of the report. Among other things, it may be used to print the page number automatically. For example:

iation in the numbers of lines printed in a PAGE TRAILER block. In other words, the number of lines printed by the PRINT and SKIP

s must be the same in both the THEN and ELSE clauses.

i)

Statem

ve associated with it one or more statem trol block tells ACE when to do it. Statem , and expressions such as adrs1 clipped.

quired to separate the information lines in a report into groups, and to print a heading before, or a total after the group, based on information contained within the group. This is k processing.

OsO d in the control block header changes value and each time a more significant column changes value. No( R or BEFORE GROUP OF clause. (ii) You may include one AFTER and/or BEFORE GROUP OF control block for every column

(

Is

This block specifies w

Page trailer Print today using "dd/mm/yy", Column 60, pageno using "<<"

Notes: (i) An IF THEN ELSE statement must not allow any var

statement

(i You cannot use the PRINT FILE statement in a PAGE TRAILER control block.

ents

Each of the control blocks mentioned above must haents. A statement actually tells ACE what to do; a conents are made u of keywords, such as LET or PRINT

GROUP PROCESSING

It is often re

nown as group

A group of rows is defined as all rows that contain the same value for given column. Using an RDER BY clause in the SELECT section automatically groups the rows according to the columns pecified in the ORDER OF clause. ACE processes the statements in an AFTER or BEFORE GROUP F control block each time the column specifie

tes i) the construct table. column is not allowed in an AFTE

specified in the ORDER BY clause of the SELECT statement. iii) The Order in which AFTER and BEFORE GROUP of control blocks are processed for an

ORDER BY clause of the form:

Order by a, b, c,

as follows

Page 137: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

136

before group of a before group of b

BEFORE GROUP OF

ACE processes the statements in a BEFORE GROUP OF control block at the beginning of the port, each time the specified column changes value and each time a more significant column

hanges value. The syntax for this control block is:

BEFORE GROUP OF column-name [int1[,int2]] Statement(s)

Int1 and int2 are optional subscripts that you can use with a type CHAR column to a subset of e column beginning at character position int1 and ending at character position int2. If int2 is not

, the end of the column is used.

Before group of owner [1,3]

The BEFORE GROUP OF control block is most often used to print column headings. For example:

Before group of county Skip 1 line

Print "Houses for", county Notes: (i) When the statements in a BEFOREGROUP OF control block are processed, the columns that

the report is currently processing will have the values from the first row of the group. (ii) Group aggregates (GROUP TOTAL, GROUP COUNT, etc.) may only be used in AFTER

GROUP OF control blocks AFTER GROUP OF

Program processes the statements in an AFTER GROUP OF control block each time the

specified column changes value, each time a more significant column changes value, and at the end of the report. The syntax for this control block is :

AFTER GROUP OF column-name[int1[,int2]]

S

before group of c on every row after group of c

after group of b after group of a

rec

thspecified

tatement(s)

Page 138: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

137

Int1 and int2 are optional subscripts that you can use with a type CHAR column to refer to a subset of the column beginning at character position int1 and ending at character position int12. If int2 is not specified, the end of the column is used.

r group of owner [1,3]

Skip 1 line Print "Total for ", agent, " = ",

Group count using "<<"

ntrol blocks.

Certain statement such as FOR and IF THEN ELSE will only allow single statements within their clauses. Multiple statements, may be included by the use of a compound statement, which is a group of statement, which is a group of statements bracketed by the words BEGIN and END. For example: If county = "Berks" Then Begin Print "Berkshire" Skip 1 line End Else Begin Print county Skip 1 line End

Afte

The AFTER GROUP OF control block is particularly appropriate for the printing of sub-totals.For example: After group of agent

Skip 2 lines Notes (I) When the statements in an AFTER GROUP OF control block are processed, the columns that

the report is currently processing will have the values from the last row of the group. (II) Group aggregates (GROUP TOTAL, GROUP COUNT, etc) may only be used in AFTER

GROUP OF co

Page 139: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

138

12. INFORMIX-4GL

Overview

• This chapter contains a high-level overview of INFORMIX-4GL Its aim is to orient you to the capabilities and typical uses of the product, and to answer general questions such as what kind of software 4GL is and what is it used for.

Whatis4GL? 4GLis a full-featured, general-purpose, fourth-generation programming language with special facilities for producing the following:

• Database queries and database management using the Structured Query Language (SQL). • Reports from a database or other data. • Form- and menu-based multi-user applications.

These s ures make 4GL especially well suited to developing large database applications. pecial feat

4GL Provides a Programmer's Environment

4 s a Programmer's Environment that makes it easy to create, compile, and maintain large, GL providemulti-module programs. Within the Programmer's Environment, you can:

• Create new program modules and modify existing modules. • Compile individual modules and entire applications. • Create and compile forms used by the application. • Run compiled applications. • Use INFORMIX-SQL to interact with an Informix database. • Get help at any time by using the on-line help feature.

You can also manage your applications by using commands at the operating system prompt rather than using the Programmer's Environment.

4GL Works with Databases Although it is a complete, general-purpose programming language, 4GL was specifically designed

to make certain kinds of programs especially easy to write. Programs of these kinds, collectively "interactive database applications," face some or all of the following special challenges:

• ta from a local or remote database and process it with logic more complicated than SQL They retrieve da

alone permits. • They present data using screen forms and allow users to construct queries against the database. • records, often enforcing complex requirements for data validation and They allow users to alter database

security. • They update a database with data processed from other databases or from operating system files. • They generate multi-page, multi-level reports based on data from a database or other sources, often

letting the user set the parameters of the report and select the data for it.

Page 140: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

139

With INFORMIX-4GL you can program applications of these kinds more easily than with any other language. In addition, 4GL have an open, readable syntax that encourages good individual or group programming style. Programs written in 4GL are easily enhanced and extended. This, with its development environment, makes it easy for programmers to become productive quickly no matter what programming languages they know.

4GL Runs in Different UNIX Environments

INFORMIX-4GL is the only multi-purpose programming language that offers code- and display-compatibility across operating environments. Applications you develop are portable to the different platforms subject to simple porting guidelines. You can run this version of 4GL on the following types of computers:

• On UNIX character-based terminals provided by a wide variety of hardware vendors • On UNIX workstations

Informix also provides a Microsoft Windows version of 4GL

Two Versions of 4GL

Informix provides two versions of 4GL: • The INFORMIX-4GL C Compiler Version, which uses a preprocessor to generate INFORMIX-ESQL/C source code. This code is preprocessed in turn to produce C source code, which is then compiled and linked as object code in an executable command file.

• The INFORMIX-4GL Rapid Development System, which uses a compiler to produce pseudo-code (called "p-code") in a single step. You then invoke a "runner" to execute the p-code version of your application. (This version is sometimes abbreviated as .) RDS

Interfaces of 1NFORMIX-4GL

Overview Multi-user application programs you write using INFORMIX-4GL have four primary interfaces to other software:

• Accessing a database through a database engine. • Communicating with users through a terminal. • Accessing sequential files through the host operating system. • Generating reports that can then be sent to several destinations

Page 141: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Database Access

OFILMK

140

Your 4GL programs can access SQL databases using the appropriate iNFOR-Mix-OnLine Dynamic

Server and INFORMIX-SE database engines. The database engine can be located on the same-computer as the application program, but this may not be the case. Once network connection are properly established, database access is transparent; you need not write any special code to make it happen. In fact, the same 4GL program can work with a local database engine in the same computer on one occasion and over a network to an engine in another computer on another occasion.

Ac Files cess to Sequential

Your 4GL application can use standard sequential, or flat, data files in the following ways: • The UNLOAD statement writes selected rows of data to a specified file • cified file and inserts its lines as rows in a database table The LOAD statement reads a spe• The START REPORT or the REPORT statements can send output from a report to a specified sequential file or

an operating system pipe • GL The PRINT FILE statement can incorporate .the contents of a specified sequential file into the output of a 4

report • The DISPLAY statement can be used to write lines to the Application window. Using the host operating

system you can direct these lines to a file or another program

Report Output

Your 4GL program can generate powerful and flexible reports. The output of a report is a series of print lines. This output can be directed to any of several destinations:

Interactive users or database Database

Page 142: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

141

• A screen • A printer • A host system sequential file, specified by its pathname • A UNIX operating system "pipe" to another process.

The logic for generating reports is the same in all cases. The destination can be coded into the program or selected at execution time. Report programming is covered in more detail in Part II, with examples in Part Hi of this book.

User Access

To provide for portability of code across different platforms, your program interacts with the-user through windows with a fixed number of rows and character-width columns. The user of your application may be using any of the following:

• A terminal-emulation program in a personal computer or workstation that is connected to a UNIX network.

• A character-based terminal connected to a UNIX system. The key point is that for matter what the display device, the 4GL user inter-face is programmed in terms of fixed-size characters; that is, so many columns across by so many rows down. Forms are also portable across applications and platforms. You design screen forms through which your program can display data; then you compile the forms separately from the other parts of the program. Thus the compiled forms can be used with different programs. You display a form with one program statement and fill it with data in another; you can prompt for user input from any or all fields with a third. You can easily open additional display areas for alerts and other information. Interaction through a hierarchical set of ring menus (horizontal menus) is also fully supported.

Using Forms and Menus The typical 4GL program is designed around a hierarchy of screen forms and menus. The program presents a main menu containing a list of major activities, for example query, insert, or update. The user makes a selection of one activity and the program displays the form for that activity. When the activity ends, the program redisplays the main menu.

Page 143: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

142

High-level view of a program with three major forms The key characteristic of a 4GL program is that the program chooses which screen elements the user interacts with at any particular time. This pre t-ability leads dic to an easily maintained linear program structure and simple program logic.

Summary You use 4GL to write programs that connect key elements in the following informational structure:

• The database • The interactive users of the database • Common data files • Database reports

In dealing with 'the database, you use the industry-standard Structured Query Language, that you can augment with custom programming logic. As you will see in subsequent chapters, your programs have a simple method for access to common sequential files, and a nonprocedural, task-oriented method of getting information from a database and defining and producing reports. You can use 4GLto program elaborate user interactions based on forms and menus. This user interface is character-oriented; that is, output is displayed in a fixed number of evenly spaced lines, each of which contains a fixed number of mono space characters. This approach allows applications written in 4GLto run without modification on supported platforms.

Page 144: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

143

12. The INFORMIX-4GL Language

Overview

This chapter provides a brief tour of INFORMIX-4GL as a language. The purpose is to give you an idea of what 4GL code looks like. There are many short examples in the following chapters and several complete examples supplied on-line with the product.

As a programming language, 4GL has several important features:

• It is a procedural language, with facilities for structured programming.

• It is a nonprocedural ("fourth-generation") language with regard to:

o Database access o Reports o Form-based user interaction

• It is C-like in design, but much easier to read, write, and support.-

A Structured, Procedural Language

4GL is a general-purpose programming language for creating structured programs, the way you might use Pascal, C, COBOL, or PI/1. Like these languages, 4GL offers statements you use to perform the following tasks:

• Declare variables of different types

• Calculate values and assign them into variables

• Declare functions

• Apply functions to data

• Display the contents of variables on the screen

Also like other languages, 4GL has control statements you use to define choices, loops, and statement blocks of code.

Here is a short, complete program in 4GL. It prompts the user for a number and displays the square, cube, and fourth power of the number.

Page 145: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

4GL is not sensitive to the letter case of a source statement. The use of all-capitals for language keywords such as DEFINE and MAIN is merely a convention used in these manuals. You are free to write keywords in lowercase, or any combination of capitals and lowercase you prefer.

The 4GL language supports structured programming. Its design encourages you to build your program as a family of simple, reusable functions with well-defined interfaces. The following, -function returns the lesser of two integers.

As described in the next chapter, 4GL also has features making it easy to assemble large programs from many small source modules:

OFILMK

144

A Nonprocedural, Fourth-Generation Language

4GL is a nonprocedural, or "fourth generation" language in three important areas: • Database access • Report generation • User interaction

Page 146: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

145

In l these areas you specify what is to be done, while 4GL (or the database engine) takes care of the actuasequence of events.

Database Access 4GL inclu guage (SQL) statements as native statements of des all Informix 4.1-level Structured Query Lanth rice to all the items in the stock table that are e language. The following function applies a change in pp returns the number of rows changed to the urchased from a particular manufacturer. The function calling routine.

It nts to be nonprocedural, that is, you use the statements to specify is the nature of many SQL statemew tabase engine determines how to do it. hat is to be done, and the da

However, using 4GL you can write code that applies sophisticated logic to the results of the SQL s lidate the tatements. For example, the function in the preceding example could contain statements to vaargument b rf rm such a efore applying the change, or to verify the authorization of the current user to pe ochange.

Report Generation

A rt is an organized display of data epo that has been extracted from the datebase. Reports are often rtabular , and designed for printing with page headings and footings. in form can be voluminous in sizeFrequently reports are produced by non-interactive, "batch" programs, perhaps run at night. Any 4G program can produce a report.

4GL divides the task of producing a report into two parts. One part, which may require procedural logic, is the production of header and footer lines detail lines, control breaks, and display subtotals.

You write the logic of the report in a nonprocedural form, as a collection of code blocks that are called automatically as needed. For example, your code block for a group subtotal can be executed automatically on each change in the value of the group control variable. Your code block for a page footer is called automatically at the bottom of each page.

Page 147: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

146

Thus, as you design a logic of a report, you think about each part of the report in isolation. nd code the4GL supplies the "glue" vokes the report sections as required. logic that in

One key point: the part of the program that produces the data rows does not need to arrange the rows. 4GL can automatically collect generated rows and sort them before presenting them to the report code, if that is necessary.

User Interaction 4GL c riting interactive programs. The following illustration shows a typical ontains extensive support for wscreen form with a menu, together with the pseudocode, that would be used to display it. Yo arately from program code. Since u describe a screen form in its own source file and compile it sepform ifferent 4GL applications. s are independent of 4GL programs, they are easy to use with many d

You can fill some or all of the fields of a form from program variables with a single statement. With another statement you can open up form fields for user input with the entered data returned to program variables. ds. The code is executed For detailed validation, you can attach blocks of code to form fielwhen the cursor leaves or enters a field.

You can o top of the current 4GL window, pen a 4GL window, optionally containing another form, over theand then lists of data both for display and restore the original display. There is support for scrolling editing.

Summary

4GL has all the features of a standard, structured programming language. It goes beyond such languages as Pascal or C in that it supports nonprocedural, task oriented ways of programming database access, report generation, and user interaction.

Page 148: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

147

13. PARTS OF AN APPLICATION Overview

You typically use INFORMIX-4GL to build an interactive database application, a program that mediates between a user and a database. The database schema that organizes data into relational tables gives shape to one side of the program. The needs of your user shape the other side. You write the program logic that bridges the gap between them.

Such a program has many parts that you prepare with the help of the 4GL Programmer's Environment. The main parts of an application are:

Form source files You specify the user interface to your application using editable files that specify the appearance

of a form on the screen and the data types and attributes of the fields in the form.

Form object files Your form specifications are compiled into a binary form by using FORM4GL, the 4GLform

compiler. These are loaded by the program during execution.

Message source files You write the text of help messages and other messages separately from your programs. You can use a common set of messages for multiple programs, and you can change these (for instance to1 support a different language) independently of the programs.

Message object files Your messages are indexed for rapid access by mkmessage, the 4GL message compiler. Like a

form, a compiled message file can be used by many different programs.

Program source files You write your program as one or more files of 4GL source code.

Program object files Your sources are compiled into C code or p-code executable

-____; Jiles, depending on the version of 4GLyou are using.

Page 149: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

P ation arts of a 4GL applic

The Database Schema

In the structure of the database, either you or another person acting as the Database Administrator (DBA), carefully design a representation of the real world, or an important part of it.

This picture of the real world is expressed in the form of tables of information each containing categories of information called columns. It is not simple to make the proper choice of columns and to group them into tables so that the data can be used efficiently and reliably as your needs change. In fact, many books have been written on the subject of how best to design a database structure, usually referred to as a schema.

OFILMK

148

Page 150: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

149

The database schema affects your 4GL program in many ways:

• You can have program variables that have the same data types and names as database columns. 4GL makes this easy by let is ting you declare a variable as being LIKE a column in a table. When the program compiled, the compiler queries the database for the appropriate data type. • Your program can contain SQL statements that refer to names of tables and columns. Any change in the schema may require you to examine these statements and possibly change them. • The logic of your program may depend on the schema. For example, if your program has to change the ema of several tables in performing a certain operation, you may want to use explicit database schtransactions; while if the data is arranged so that only a single table needs changing, you can avoid this.

In general, before you start work on a large application, you should make sure that the database schema is workable and that you and others who will be using the database understand it well.

Form Specifications and Form Files

In many applications the user interface is defined by forms. A form is a fixed, functionally organized arrangement of fields (areas where you can display program data and the user can enter text) and labels (static, descriptive text).

The user of a program does not know about the database schema nor your carefully-designed program lo are the application. The gic. As the user sees it, the forms and the menus that invoke themarrangement of fields and labels, and the behavior of the forms as the user presses different keys and selects different menu options, create the personality_ofihe—-"~ program. . - ~~~

ing labels, fields, additional text and a screen array

A form contain

Page 151: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

150

4GL form specification files are ASCII files. You can use an ASCII text editor to design the labels and fields for your form. Here is a portion of the form specification file used to create the preceding form:

SCREEN { Customer Number: [fOOO ] Company Name: [fOOl ] Order No:[f002 ] Order Date:[f003 ] PO Number: [f004 ]

Item No. Stock No Manuf Description Quantity Price Total [f005 ] [f006 ] [fO7] [f008 ] [f009 ] [fOlO ] [foil ] [f005 ] [f006 ] [fO7] [f008 ] [f009 ] [fOlO ] [foil ] [f005 ] [f006 ] [fO7] [f'008 ] [f009 ] [fOlO ] [fOll ] [fOO5 ] [f006 ] [fO7], [f008 ] [f009 ] [fOlO ] [fOll ]

Sub-Total: [fO12 ] Tax Rate [fO13 ]% [fO14 ] Sales Tax: [fO15 ]

— — — — — — — _ _ _ _ — • • _ _ . « • _ _ - . . • • _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ . _ _ . _ _ _ _ _ _ _ . _ _ Order Total: (fO16 ] } TABLES . customer orders items stock state . ATTRIBUTES fOOO = orders.customer_num; fOOl = customer.company;

After specifyi FORM G result is a portable binary ng a form, you compile it with *4 L, the 4GL form compiler. Thefile that can be opened and displayed from any 4GL program on any platform supported by 4GL.

The form compilation process Compiled forms are independent of the programs that use them, so you can use the same forms in different applications for a consistent "look and feel."

Page 152: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

151

Since forms are so important to the users of your application, you should consider designing the main forms before any other part of the program. You can quickly prototype programs that display forms so your users can give you their opinions.

Here is the text of the program that displayed the form on previous page:

MAIN OPEN FORM fx FROM "f orders" DISPLAY FORM fx DISPLAY "2478" 'TO orders.customer_num DISPLAY "Overachievers, Inc" TO customer.company SLEEP 60 END MAIN

Form Design

Although u design is both an art and a science, most form designers are neither scientists ser interface nor artists. Here are a few points to consider when creating forms for your application:

• Is the purpose of the form clear from its title and the title of the menu command that invokes it? • Are fields in the fo llows in transcribing rm arranged in the same logical order that the" user typically fo

or describing the information? • Is the same information always given the same label in every form in which it appears? • Are form labels consistent instyle and content? • Is the relationship between various-fGfmjfas clear as possible? • Is it obvious how to complete the form and what fields are required?

Field Entry Order

With -4SL.you can constrain the user to entering fields in a preset order or you can permit entry into fields in any order. desired by the user.-Since_application and form requirements differ, you can control these factors on a form by form basis

Page 153: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

152

Page 154: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

153

Program Source Files

You express the logic of your application with 4GL statements in program source files.

Organization of a Program

If files containing executable 4GL statements require you are using the C Compiler Version of 4GL, theth nnot find them). However, if you are using the RDS e file suffix .4gl (otherwise the program compiler cave .4gl file suffix. rsion of 4GL, you can omit the

Executable statements are organized as program blocks. A function is a unit of executable code that can be called by name. In a small program, you can write all the functions used in the program in a single file. As programs grow larger, you will usually want to group related functions into separate files, or modules, with the declarations they use.

Each source file usually reflects a self-contained unit of program logic; source files are sometimes called source modules.

Exe module cution of any program begins with a special, required program block named MAIN. The sourcethat MAIN is called the main module. Here is a small but complete 4GL program: contains

MAIN CALL sayltO

END MAIN FUNCTION say 11() DISPLAY "Hello, world!"

END FUNCTION

Th d ND is_sinoje_ module contains the MAIN program block, delimite by the statements MAIN ande EMAIN, and one other function named saylt(). A single fun ver, since the program above has two ction cannot be split across source modules Howefunctions it could be split into two source modules.

The first would look like:

Page 155: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

154

The second module could contain the three lines of function saylt() just as shown above. It could also contain data or other

functions related to saylt(), if there were any. Functions are available on a global basis. In other words, you can reference any function in any source module of your program.

The Globals File In 4GL programs, global variables (variables available to more than one source module) are declared in a globals file and referenced through the GLOBALS statement by each 4GL module that uses them.

Program Object Files

The C Compiler Version and the Rapid Development " System of 4GL each provide its own source code compiler. These compilers generate distinct, executable forms of the same program:

• c4gl, the C code comp iler provided with the C Compiler Version, generates code that can be executeddirectly by the hardware of the computer after an executable program is created.

• fglpc, the p-code compiler provided with the Rapid Development System, generates hardware independent code— ystem code not directly executable by the operating sor GUI—that is interpr 4GL p-code runner. Both can take the same 4GL source-code as input. If eted by thethe C code option is file is linked with other selected, the output is a C language object file. When this 4GL libraries and pe t executable program is produced. rhaps C object modules, an independen

The C object code generation process

tion is chosen, p-code int ject files are created that

are executable under the 4GL runner. P-code stands tor pseudo-machine code. Both types of compiled printable or edit-able as tex modules of an application

mpiled t rm; that is, the executable version of your program cannot mix C code and p-code units e p-code runner can be custom C object modules.

If the p-code op ermediate ob

files are binary. That is, the file is not t. All of thehave to be co o the same fo

, although th ized to call

Page 156: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

155

P-code Object Files

You can use fglpc, the p , to translate rce modu de. The output of the p--code compiler a sou le into p-cocode compiler will have t . he file suffix .4go

The p-code object code generation process

. When your application is in several source modules, you first compile each separate module to p-code. Then tenate the individual p-code files using a utility (cat in UNIX environments) to -you can concamake the executable .4gi program file.

Note: When yo mer's Environment to build and maintain your program, module linking u use the Programis done automatically for you.

S cutable program under the p-code runner

teps to creating an exe

Page 157: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

156

To tions in the execute a .4gi file you call the 4GLp-code runner. Use fglgo to execute the p-code instrucfile, bringing your program to life, metaphorically speaking.

Components of a runnable p-code application program

C Code Object Files Y source module directly into machine code. ou can use the Informix C code compiler, c4gl, to translate aThis is done in three primary stages:

1. UC source code. The module is translated to INFORMIX-ESQ2. The ESQL/C processor converts that to C source. 3. The

From the operating system command rms all the steps, or all these steps can u ' automatically accomplished through the Programmer's Environment.

compiler translates to C object code for your computer.

Steps to creating a C 4gl object

line a single call to the c4gl command perfo

On UNIX systems the default extension is .4ge. However, it is hot required. You may name your executable applications anything you like.

Page 158: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

The C file from a single sou .o files for a multi-module rce module is compiled to an .o file. Several application can be combined le file through the Programmer's Environment or into a single executabusing another concatenation u mmand line accepts any combination of .4gl files, tility. In fact the c4gl co

OFILMK

157

.ec files, .c files, and .o files to produce a file.

single .4ge executable

Linker

Steps to creating an Indepe

ndently executable 4GL program

Page 159: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

The Procedural Language Overview

. INFORMIX-4GL is a fourth-generation programming language. However, it uses some concepts based on procedural languages (such as Pascal and C). This chapter describes the concepts based on proc ; in particular, it describes how to: edural programming• Declare variables • Organize statements for decisions and looping • Handle exceptions

Declar tion of Variables a

4GL ha variables. You specify a type for every variable, but s a flexible mechanism for declaring programthere is automatic conversion between many data types. Data can be organized as records or arrays. It can be allocated statically or dynamically and can be declared at several scope levels.

Variables Definition, Initialization, and Scope

Variables of all types are declared and their data type is identified in the define statement as follows:

define <varnarne> <datatype> , ...I

Variable naming to apply to INFORMIX-4GL programs a very simple naming arrangement uses a p_prefix to. id iables, an s_prefix to define screen records in forms, and a pa_prefix entify program varto identify pro n records in forms. A more comprehensive gram arrays, and an sa_prefix to define screenaming set is shown in table given below.

__________ r ____________________________________ Variable name Used fo

g_<vamame> Global Variable. p_<va rd [program variables. mame> Non-reco

r_<vamame> Record program variables. a_<varname> awiSS Array progranrvaTi

ra_<varname> Array of record variables. s_<record> Screen record in form definitions. _____________________ sa_<record>_______ Screen array records in form definition.

OFILMK

158

Page 160: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

159

Scope of Reference

local

module

The scope of a variable name is the range of program statements over which it can be used. 4GL has several scope levels. In summary, the levels are:

Names declared within a program block are local to the program block. Their scope is from the point of declaration to the end of the program block. The variables are created each time the function, report, or MAIN statement is entered and cease to exist when the program block terminates.

Names declared outside of any program block are local to the module. Their

global

scope is from the point of declaration to the end of the module.

Variable names declared with the GLOBALS statement are global to the program. The GLOBALS statement is also used to specify a file of globally available variable declarations in each source module that uses the global variables.

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.

Naming Conventions for Variables

Global Record Program Object Prefix Example and Arrays global records gr_ gr_customer

global arrays ga_ ga_items global variables g_ g_custnum

Trail records nr_ nr_customer

Module Record Program Object - Prefix Example and Arrays module records mr_ mr_currcust

module arrays. ma_ ma_stack ___ module variables m_ m jTextiterrT

Local Record Program Object Prefix Example and Arrays local records lr_ lr_orders

local arrays la_ la_manuf local variables no prefix stock_cnt

Page 161: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

160

Screen Record Program Object Prefix Example and Arrays screen records sr_ sr_customer

screen arrrays sa_ sa_items screen variables no prefix stock_num

Other Record Program Object Prefix Example and Arrays cursors no prefix cust_ptr

wndows w_ w_cust forms f_ f_customer prepared statement ex_ ex_selsmt record elemen LIKE same name asd the tables ts defined

column

Data Typing 4GL is a "strongly typed" language. That is, whenever you declare a program variable you must specify its data type, for example, INTEGER or . The compiler ensures that only data of that type can be CHARstored in that variable. Here is an example declaration of several types of variables:

DEFINE aFloat FLOAT onelnt, anotherlnt INTEGER, aString CHAR.(20)

The data types supported by 4GL for program variables include all the data types that are allowed in a column in a database except SERIAL. This includes BYTE and TEXT, the Binary Large Object (blob) data types.

An important point to note is that 4GL defines a specific NULL value for every data type. Null means "unknown," rather than 0, which is a precise value. You can assign NULL to any variable, and you can test any variable for NULL content. This is necessary to properly support database access, since NULL is a distinct value (or, to be precise, non-value) in a database table.

Automatic Data Conversion

With s nto a variable of a ome strongly-typed languages, it is an error to assign a value of one type idifferen . By contrast, 4G ny variable prov ed that there is a t type L allows you to assign any value into a idreasonable way of converting between the type of the value and the type of the variable.

LET aFLoat =2.71828 LET onelnt = aFloat -- assigns integer 2

The LET statement is used for assignment. The first of the preceding LET statements assigns a literal decimal number into a variable of type FLOAT.

In the second LET statement a FLOAT value—the contents of the variable.

aFloat—is assigned to match the integer variable onelnt. 4GL converts the FLOAT value into an integer to type of the receiving variable. To do so, the fractional part of the floating point number is truncated.

Page 162: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

161

One conversion that is often used is between a character value and almost any other type.

LET aString = aFloat-- assigns "2.71828" to aString

The above statement assigns a FLOAT value to a variable whose type is CHAR (character string). 4GL converts the numeric value to characters and assigns that string value to a String.

4GL will also attempt to convert a character string back into a numeric or other type. The following statement assigns a string of numeric characters to a FLOAT variable:

LET aString -'"3.141592" LET aFloat « aString -- assigns 3.141592 into aFloat

If the characters in the string can be interpreted as a literal value of the type needed, the conversion is done. Most data types have a printable, character representation, and 4GL converts automatically between the printable form and the internal form.

Of course there are some cases when conversion is not allowed; for example, the BYTE and TEXT data types cannot be converted into any other type. Such errors are detected at compile time.

Some conversions can only be found to be impossible at execution time. The following example fails in its attempt to Convert a large floating point number to integer.

LET aFloat, = 2E12 -about 100 times the maximum integer size LET onelnt = aFloat - this causes a runtime error

You can manage such errors by: • Anticipating them and inserting programmed tests to avoid

them. . • Trapping the error at execution time • Letting the run-time error terminate the program with an

appropriate message

(Defining Explicit Variables) syntax

DEFINE variable-list 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

Data Structures

Besides simple typed variables, you can organize program data into records and arrays (also known as data structures). Records A record is a group of variables that are treated as a unit. Each member of a record has a name. The following code fragments defines a record:

Page 163: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

162

DEFINE stOckRow, saveStockRow RECORD stock_num INTEGER , manu_code CHAR(3) ,

description CHAR(15) , unit_price MONEY(8,2) ,

unit CHAR(4) , unit_descr CHAR(15) END RECORD

T atement fines two pr saveStockRow. Each his st de ogram variables. Their names are stockRow andvariable is a record with Six members.

The member named-tRanu code is a three-character string. You refer to this member of stockRow.manu_code. The parallel member of the other record, saveStockRow, would be called saveStockRow.manu_code.

The members of these records are all simple data types. However, a record can contain members that are other records or arrays.

A ting aspect of the record is that it contains one member for each column in the stock nother interestable of the stores demonstration database. Because it is so common to define a record that matches one-for-one to the columns of a database table, 4GL has an easier way of doing this.

DEFINE stockRow, saveStockRow RECORD LIKE stock.*

This statement causes the 4GL compiler to refer to the database, extracts the names and types of all the columns, and inserts them in the program. In this way, you can ensure that the program will always match the database schema.

You can also fetch a row of a database table into such a record.

SELECT * INTO stock StockRow.* FROMWHERE stock_num = 309 and manu_name = "HRO"

You can assign the contents of all the members of one record to another record with a single statement.

LET saveStockRow.* = stockRow.*

You can do this even w are not defined identically. The assignment is done member-hen the two records by-member. As long as the records h m each member on ave the same number of members, and data frothe right can be converted to the typ you can assign e needed by the corresponding member on the left, the contents of one record to another. The members of these records are all simple data types. However, a record can contain members that are other records or arrays. Another intere pect of the record is that it contains one member for sting as each column in the stock table of the stores demonstration database. Because it is so common to define a record that matches one-for-one to the columns of a database table, 4GL has an easier way of doing this.

Page 164: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

163

DEFINE stockRow, saveStockRow RECORD LIKE stock.*

This statement causes the 4GL compiler to refer to the database, extracts the names and types of all the columns, and inserts them in the program. In this way, you can ensure that the program will always match the database schema. You can also fetch a row of a database table into such a record.

SELECT * INTO stockRow.* FROM stock WHERE stock-_num = 309 and manu_name = "HRO"

You can assign the contents of all the members of one record to another record with a single statement.

LET saveStockRow.* = stockRow.*

You can do this even when the two records are not defined identically. The assignment is done member-by-me er. As long as the records have the same number of members, and data from mbeach member on on the right can be converted to the type needed by the corresponding member the left, you can assign the contents of one record to another.

Defining Variables as Implicit Record

Syntax: DEFINE record-name RECORD LIKE table.* Example: 1.

Database stores DEFINE cust_all RECORD LIKE customer.*

DATABASE stores DEFINE cust_some RECORD fname LIKE customer.fname, Iname LIKE customer.lname END RECORD DATABASE stores DEFINE

fname LIKE customer.fname,

Page 165: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

164

start_date LIKE orders.order_date, x,y,z LIKE orders.order_num

Any item you want to re-initialize the gr_customer record TO NULL, simply repeat the LET-statement This is only recommended for records that must be frequently initialize TO NULL.

It is always good idea to initialize your program variables. There... are two statements that can be used to initialize your variables. LET and INITIALIZE. The INITIALIZE statement is used specifically for initializing variables and records to NULL.

Arrays An array is an ordered set of elements all of the same data type. You can create one-, two-, or three-dimensional arrays. The elements of the array can be simple types or they can be records.

DEFINE stockTable ARRAY[200] OF RECORD LIKE stock.*

This array variable is named stockTable. It contains 200 elements each of which is a record with as many members as there are columns in the stock table in the database. One of those columns-is named stock_num. You would access the stock_num member of the 52nd element of the array by writing stockTabte[52].stock_num.

The first element of any array is indexed with subscript 1. (This differs from the C language, where the first element is always number zero.) The sub-script value that selects an element can be given as an expression.

Data Allocation

4GL supports the allocation of program variables either statically, as part of the executable program file, or dynamically, at execution time. You choose the method to use by the location of your DEFINE statement in the source-module.

Page 166: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

Module-level variables are allocated statically.

Local variables are allocated dynamically whon the function Is entered.

• Variables that you declare outside of any function are at the module level of the program. They are allocated statically, at compile time, and become part of the program image. They may be referenced by any function in the source file that follows the definition.

• Variables that you declare within a function are local to the function. New copies of these variables are created each time the function is called. They are discarded when the function exits.

Decisions and Loops 4GL has statements for lopping and decision-making comparable to other computer languages. Here is a brief summary:

IF...THEN...ELSE Tests.Boolean (yes/no) conditions CASE Make multiple-choice decisions WHILE eral loops controlled by a Boolean condition Used for genFOR Used for loops that iterate over an array *Tl

There is also FOREACH, a special loops used for database access, These control statements can be nested one within the . other to any depth. A key point is that their syntax is very simple and regular:

• Every statement that can contain other statements is closed with its own END statement (IF is closed with END IF, CASE with END CASE, and so on).

• Every looping statement has a specific optional early exit statement (you leave a WHILE with an EXIT WHILE, a FOR with an EXIT FOR, and so on).

• No special punctuation is needed in 4GL code. You do not need to put semicolons between statements as in C or Pascal (although you may if you like).

OFILMK

165

Page 167: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

166

Nor do you need to write parentheses around a Boolean condition as in C (but you may if you like) 4GL also supports GOTO...LABEL statements.

Page 168: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

167

Statement Blocks Many 4GL statements such as LET and CALL are atomic; that is, they contain only themselves. Others are compound; that is, they can contain other statements. The most common examples of compound statements are:

iF-THEN-ELSE • then and else each introduce a block of statements. The ELSE block is optional. FOR . ' The body of a FOR loop is a block of statements*-, WHILE The 'body of a WHILE loop is a block of statements': CASE . WHEN and OTHERWISE each introduce a block of

statements .

Statement-blocks can be nested; that is, one compound stateme ontai another. nt can c n

Here is a code fragment from Example 9, INF0RMI.X-4GL by Ex t contains a nested IF statement ample, thablock:

Comments

Y #) for individual lines (see ou can comment your 4GL code using double hyphens (--) or the pound sign (the s Qf code. previous code fragment) or curly braces ({and }) for multiple contiguous line

Exceptions An exception—also known as an error condition—is an unplanned event that interferes with normal execution of a program. Usually an exception is not expected to occur in the normal course of events, arid it requires Special action when it does occur. Kinds of Exceptions

There are several kinds of exceptions; they can be categorized this way:

run-time errors Errors in program statements detected by 4GL at run time. These errors are divided into groups based on the kind of statement:

File I/O Errors using files managed by the host operating system.

Page 169: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

168

Display Errors using the screen. Expression Errors in evaluating 4GL expressions; for

instance, a data conversion error or an invalid array subscript. SOL error Errors reported by the

database engine.

S ave reached the end of a set of rows OL end of data Warnings that you hbeing fetched through a cursor.

SQL warning A warning condition reported by the database engine. external signals Events detected by the host operating system. An external signal is usually not

directly related to the program's statements. Two common external signals that 4GL can handle are Interrupt (C0NTROL-C) and Quit (CONTROLA).

Why Exceptions Must Be Handled

Exception bability. Usually your program s are unplanned in the sense that they are events of low procannot pre y are always unexpected. For dict or control when they will occur. This does not mean that theexample:

• ot always know You are certain that there will be an end to any selection of rows, it is just that you do nwhich row-will be the last.

• You are sure that some user-will eventually try to cancel an - operation, but you do not know When.

Alas, even run-time exceptions must always be anticipated, no matter how carefully you write your code. Because program exceptions are sure to happen, you must design the program to handle them in a rational manner. But because they are of low probability, you want to handle them:

• Away from the main line of processing, so the code for the normal, expected

sequence of events is clear and readable. • With a minimum of overhead at execution time.

How Exceptions Are Handled

Unless you e xceptions, 4GL takes the following actions when one occurs: stablish some way of handling e

run-time error the program is terminated run-time warning

execution continues

When a run-time error is encountered, any SQL transaction in progress is automatically rolled back. Then 4GL writes a is by default the screen. (You can establish an error log file message to the error log, which on disk if you wish.)

Page 170: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

169

Note: If your database is ANSl-compliant, then by default the program tries to continue if a run-time error is encountered.

For many exceptions, the default response is correct; the program should be terminated with a message. But there are other types of exceptions that you can anticipate and handle with 4GL statements including:

DEFER establishes your program's policy for handling external signals that 4GL recognizes. The DEFER statement can be used to instruct your executing program to set built-in global variables—rather than terminate the program— when an Interrupt or Quit signal is generated by the user. By polling the-variable-you can determine when the user is ready to end a routine and respond accordingly and in an orderly manner to the request.

WHENEVER ERROR establishes your program's policy for handling an execution error.

WHENEVER Ayy ERROR tests for a response to an expression error. ' WHENEVER WARNING tests for SQL warning flags. WHENEVER NOT FOUND can be used to determine when an executing SQL

statement has encountered an "end of data" condition.

Page 171: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

170

14. DAT ORTS ABASE ACCESS AND REPOverview

One of the main reasons to use INFORMIX-4GL is the ease with which you can access and modify data in a database. SQL, the Structured Query Language that is the international standard for relational database access, is an integral part of the 4GL language. Another reason to use 4GL is the ease by which you can design and generate reports.

Using SQL in a 4GL Program

There are three ways you can use SQL in a 4GL program:

1. Incorporate nonprocedural SQL statements as 4GL program statements. Any SQL statement that does not return data to the program (for example, ALTER, CREATE, UPDATE, or REVOKE among many), can be written into the program for execution • in sequence with other 4GL statements. In many cases, you can use data from program variables as part of the statement.

In addition, any SELECT statement that returns a single row of data can be written into the program and used to get data from the database and assign it to variables.

2. Use a database cursor to access a selected set of rows, one row at a time. A cursor contains a SELECT statement that may return multiple .v,w3 of data. You use an OPEN statement to start the selection. You use FETCH statements to fetch one selected row at a time, assigning the column data to variables. In this way, your program can scan a selection of rows, or bring all or part of the selection into memory and store it in an array. The FOREACH loop is another mechanism that can be used to open a cursor and fetch rows in sequence.

3. Use dynamic SQL to prepare new statements at execution time. You can assemble the text of an SQL statement from user input, then pass it to the database engine for execution. In this way, you can write an application that adapts to the schema of the database or to user-selection criteria at execution time.

Note: In this version of 4GL you can include anylevel-4.1 SQL statement. If you want to include SQL statements introduced after version 4.1, you must prepare the statement before including it in the program. (you prepare a statement by using the PREPARE statement)

Creating 4GL Reports

A report is a display of data. A well-designed report is arranged so that the eye*of the reader can easily pick out the important facts, such as column totals or sub-totals. The data can be shown on a screen or written to a printer or file. A report is meant to be viewed on the screen or on paper, so it needs to be arranged in pages, often with a heading and a footer on each page, possibly with page totals.

Page 172: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

171

The most important technique for making data clear to the eye is logical layout. The items in a report should almost always be arranged so that:

• The reader can quickly find an item. • Related items are near each other. • Groups of data with similar values fall together so that group

totals and sub-totals can be calculated and shown.

Page 173: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

172

It is much easier to make a report when the program logic that produces the report data is separate from the program logic that prepares the report itself. In 4GL, this separation is a natural part of the language. Any program that produces a report can be cleanly separated into the part that produces the data, and a second part that formats the report.

Report Driver Report Fonnauer

Report

The report generation process

The Report Driver '

The part of a program that generates the rows of report data (also known as input records) is called the report driver. It consists of the p_a£g of a program that: "

• Are concerned with the database and the user, not with the report format.

• Do not depend on the incidental features of a report, such as page* length.

• May produce data for multiple reports simultaneously.

• May produce report data as a by-product of other operations, for instance a report

on user productivity could be a by-product of carrying out user commands.

The key point is that the primary concern of the row-producing logic should be the selection of rows of data, not their arrangement or formatting.

In 4GL, the actions of a report driver are as follows:

1. Use the START REPORT statement to initialize each report to be produced.

2. Whenever a row of report data is available, use OUTPUT TO REPORT to send it to the report formatter.

Page 174: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

173

3. When the last row has been*se"nt; use FINISH REPORT to end the report.

From the standpoint of the row-producing side, these are the only statements required to create a report. Multiple reports can be produced simultaneously. Although data for a report usually comes from a database, it can come from any source, including the user, calculations, or sequential files. Since the report driver pays no attention to issues of page formatting, grouping, or totaling, it produces report data as a by-product of other activities.

Your program is not required to produce rows in any special order. It is generally more efficient to produce them in their proper sorted order when possible (that is, by selecting database data in the desired order using the ORDER BY • directive). However, you can produce them in any order, and leave the sorting to the report formatter.

The Report Formatter

You write the report formatter for each report in the same way as you write a 4GL function. The code within a report program i block consists of several sections:

DEFINE section Here you define variables that are local to the report. A report can have its own local variables for subtotals, calculated results, and other uses.

OUTPUT section Here you declare the size_and margins of the report page. The OUTPUT section takes effect when the report is started. ORDER section. Here you specify the required order for the data rows and whether or not the rows are provided to the report already ordered. FORMAT section Here you describe what is to be done at a particular-stage of report generation.

The code blocks you write in the FORMAT section are the heart of the report program block and contain all its intelligence. You can write statement blocks to be executed for the following events:

• Top (header) of the first page of the report.

• Top (header) of every page after the first.

• Bottom (footer) of every page.

• Each new row as it arrives.

• The start of a group of rows (a group is one or more rows having equal values in a particular column). This statement block is often used for clearing totals and other accumulated values.

• The end of a group of rows. In this block, you typically print subtotals and other aggregate data for the group that is ending. You can call on aggregate functions like SUM and MAX for this information.

• After the last row has been processed.

Page 175: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

174

You can use most 4GL statements in the FORMAT section of a report; you cannot, however, include any SQL statements. For example, you can call other functions and interact with the user.

The key point is that 4GL invokes the sections and blocks within a report program block non-procedurally, at the proper time, as determined by the report data. You do not have to write code to calculate, when a new page should start, nor do you have to write comparisons to detect when a group of rows has started or ended. All you have to write is the statements that are appropriate to the situation, and 4GL supplies the "glue" to make them work.

Page 176: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

175

15. THE USER INTERFACE

Overview Built into INFORMIX-4GL is a complete system of character-oriented user interaction. Being character-oriented, the same 4GL applications can run on supported graphical user interfaces (Guls), on personal computers, high-end workstations, and character-based terminals.

In all cases—character terminal, terminal emulation, and graphical—4GLlets you create highly flexible, portable, interactive, multi-user applications using screen forms and menus.

Line-Mode Interaction

A 4GL program can operate with its user interface in Line mode or Formatted mode. Line mode is the same typewriter-like mode of interaction that is used by UNIX shell scripts. You put the user interface in Line mode by executing a DISPLAY statement that does not specify a screen location. Here is a simple program that operates in Line mode.

MAIN DEFINE centDeg, fahrDeg DECIMAL(5,2) DEFINE keepOn CHAR(l) LET keepOn = "y" DISPLAY "Centigrade-to-fahrenheit conversion." WHILE keepOn == "y" PROMPT "Centigrade temp: " FOR centDeg LET fahrDeg = (9*centDeg)/5 + 32 . DISPLAY "old-fashioned equivalent: ", fahrDeg PROMPT "More of this (y/n) ? " FOR CHAR keepOn END WHILE END MAIN

Because the first DISPLAY statement, does not give a screen row and column for output, the screen is put in Line mode. Each line of display, and each prompt displayed by PROMPT, scrolls up the screen in the manner of a typewriter.

When you execute this program the interaction on the screen resembles the following, in which user data entry has been underscored. Centigrade-to-Fahrenheit conversion. Centigrade temp: 16 old-fashioned equivalent: 60.80 More of this (y/n) ? y Centigrade temp: 28 old-fashioned equivalent: 82.4 0 More of this (y/n) ? n

You can use simple interactions of this kind for quick tests of algorithms. Line mode also has the virtue that you can redirect Line mode output to disk from the command line. The following program displays two columns from the customer table using Line mode output.

Page 177: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

176

DATABASE stores2 MAIN- .DEFINE custno LIKE customer.customer_num, company LIKE customer.company DECLARE cust CURSOR FOR SELECT customer_num, company FROM customer

FOREACH cust INTO custno, company DISPLAY custno, company -- Line mode display END FOREACH END MAIN

You could execute this program from the command line, redirecting its output into a file, with a statement like the following (assuming the program has been compiled to 4GL p-code in a file named dump2col.4gl):

fglgo dump2col | custcols.dat

The data could also be "piped" into another command. However, there is no equivalent input statement (PROMPT only accepts input from a real, keyboard, not from a-pipeline or redirected disk file).

Formatted Mode Interaction

Normally, 4GLJKeeps the user interface in Formatted mode. That is, the output of the program is automatically formatted for screen display. The program's output is positioned by rows and columns. On character terminals, the initial 4GL window is the same size as the screen and is referred to as the 4GL screen.

Here is a brief summary of the 4GL statements you use to manage the user interface in Formatted mode.

Formatted Mode Display

In Formatted mode, certain lines of the two-dimensional screen are dedicated to certain types of information. You can change the location of these lines, but you cannot eliminate their special uses. Here are the reserved screen lines with their default positions:

Statement Purpose

DISPLAY...AT Write data at specific rows and columns. DISPLAY FORM Display the background of a prepared form. DISPLAY...TO Write data into one or more fields of a form. PROMPT Prompt the user for a single value or a one-character response. INPUT Let user enter data into one or more fields or arrays of fields on

a form. CONSTRUCT Let user enter search criteria into the fields of a form. MESSAGE Display a short message of warning or confirmation. ERROR Display a short message documenting a serious error to the

screen.

Page 178: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

177

Line Name

Prompt

Purpose Output and input of PROMPT

Default Position FIRST

Point of Reference 4GL window

statement. Menu Ring menu display occupies two FIRST 4GL window lines. Message Output of the MESSAGE statement. FIRST+1 4GL window Form Top line of any form. FIRST+2 4GL window Comment Explanatory comment for current LAST 4GL window fuitn field. Error Output of the ERROR statement. LAST 4GL screen Here is how the screen is arranged when the default line assignments are in effect.

Page 179: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

178

Menu command

The syntax for the menu statement block is as follows:

menu <menu name> command { [key (<command key> [,...]) ] [ <command

name> ] [ "<description>" ] [ help <help number> ]

}

{ [ hide option {all | <command name> [,...]] | [show option {all | <command name> [,...]] | [next option <command name>] | [continue menu] | [exit menu]

} end menu

A menu that you have coded in INFORMIX-4GL works for your end user in much the same way asa the menus in the INFORMIX-4GL Programmer's Environment.

MAIN CALL main_menu() CLEAR SCREEN END MAIN FUNCTION main_menu()

MENU "MAIN MENU" COMMAND "Customer" "Go to the Customer Menu"

CALLdummyO COMMAND~sOr4ersl"Go to the Order Menu"

CALLdummyO^ COMMAND "Stock" "Go to the Stock Menu"

CALLdummyO COMMAND "Reports" "Go to the Reports Menu"

CALL-tiui'nmyO • COMMAND "Exit" "Exit from the Menu"

EXIT MENU . END MENU FUNCTION

dummy() ERROR "Function not yet implemented." END FUNCTION

Page 180: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

179

User choose an option by highlighting the option and pressing RETURN key or by pressing the first letter of the option. If there are more options than will fit on a single line, the user sees the (...) notation as a menu choice. This means there are more choices than can be displayed on one line. The user can highlight the (...) notation as a menu choices will be presented.

1. We can decide which command options to place on your menu. 2. We can devide how many command options to place on your menu. 3. We can decide the sequence of the command options. 4. We can decide what each command-option will do. 5. INFORMIX-4GL ADDS A COLON (:) after the menu name and two

spaces between each command option. 6. The menu name (MAIN MENU) will be displayed to the left of command

options when your menu is displayed. 7. END MENU is required syntax when you use the MENU statement. 8. The EXIT MENU statement terminates the menu statement. The MENU

statement requires two lines.

The before menu clause is used to execute a collection of statements while the menu is activated and before the user can make any selections. The HIDE OPTION and SHOW OPTION statements can appear in a BEFORE MENU clause or in a COMMAND clause.

FUNCTION main_menu() MENU "MAIN MENU" BEFORE MENU

HIDE OPTION ALL SHOW OPTION "Query", "Add", "Exit" COMMAND "Query" "Query for a

row in the customer table." IF query_cust() TRUE THEN SHOW OPTION "Next", "Previous". HJpdate^aeTete^

ELSE . HIDE OPTION ALL HIDE QEIlOfet^ext", "Previous", "Update", "Delete"

END IF COMMAND "Exit" "Exit from the menu!!!!"

Exit menu END MENU END FUNCTION

Page 181: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

180

Two commands with the Same First Letter

MAIN MENU: Customer • Orders Stock States Exit Select: S[] Stock States

Or use COMMAND KEY(KEV-L/ST) MENU OPTION:

COMMAND "Stock" "Go to the STOCK Menu." CALL dummyO COMMAND KEY ("T") "sTates" "Go to the STATE menu." CALL dummy()

MAIN MENU: Customer Orders Stock sTates Exit Go to the STATE menu

In the example above, the commands Stock and sTats both begin with S. The sTates command uses the KEY option to redefine T as the letter to press for sTates. The T is capitalized to help the user recognize this; however, capitalizing the letter is not required.

• When a COMMAND clause includes a key list, the first letter of the option name no longer activates the option.

A hidden option can be created on a menu by not including an option name next to the COMMAND KEY clause. 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 other options do.

COMMAND key (CONTROL-B) CALL durSmyft—-~

Multiple options for the same command

COMMAND KEY ("E". "X") "EXIT" "Return to the operating system." EXIT MENU

In this user is given two choices for the same command. The user may press either the E or X key to exit this menu. The key listed in the parentheses is not case sensitive. In the example, there would be no need to list a lowercase e or x; they would automatically be accepted.

Multiple Menus

Page 182: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

181

FUNCTION main_menu(). MENU "MAIN MENU"

COMMAND "Customer" "Go to the CUSTOMER menu" CALLcust menu() NEXT OPTION "Orders" COMMAND "Orders" "Add a new order." CALL dummyO

END FUNCTION

FUNCTION cust_menu() MENU "CUSTOMER"

COMMAND "Query" "Search for a customer" CALLdummyO

COMMAND "Next" "Go to the next customer" CALLdummyO

END MENU END

FUNCTION In the above example if the user chooses Customer from the MAIN MENU, a call is made to the function cust_menu. This function contains another MENU statement that is displayed until the use chooses Exit. This returns the user to the MAIN MENU, and the NEXT OPTION command is executed.

This is an instruction to the menu that when returning from the CUSTOMER menu, the Orders option should be highlighted. The NEXT OPTION command allows you' to suggest a sequence of menu choices that the user should follow for your application, but it does not force the user to choose that option.

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 steps necessary to create a default form. The form name:

1. May be maximum of 10 characters long in Unix. 2. Must being with a letter, then can contain letters, numbers and

underscores (_) only. 3. Must be unique per directory

If a form with the same name already exists, you will be prompted for a different name.

You are then presented with the CHOOSE TABLE prompt. A list of available tables in the current database is presented. By using the arrow key highlight the appropriate table and press . RETURN key.

In GENERATE FORM menu three options are available.

Page 183: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

182

Table-selection-complete: Confirms table selection. INFORMIX-4GL will then compile the form into a usable state.

Select-more-tables: Allows you to include more tables in your form. You will be presented with the CHOOSE TABLE prompt and can select an additional table to be included, in this form.

Exit: Aborts the form creation process and returns you to the FORM menu.

Modifying the Default Form When you select Modify option from the FORM menu, you are presented with a list of forms that can be. modified. This is a- ljst : of form specification files.

Highlight the appropriate form and press RETURN key:

When you create a form, you are actually creating two separate files.

• An ASCII form specification files that all changes are made It has a .per extension. • A compiled version of the .per file. This has .frm extension.

Effects of Attributes In Form

The attributes section of a form specification file serves two purposes:

• It links display fields to database columns by using field tags.

• It allows you to add specific commands which determine the behavior and appearance of fields in the SCREEN section.

Page 184: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

183

ATTRIBUTES can specify: • How 4GL should format a field • Which values are acceptable for a particular field (range or edit • checking) • Comments • The default value for a field • Reverse of normal video • Upper or lower case for an entire field

Most attributes are applied only when you are adding or updating data.

ATTRIBUTES AVAILABLE

Attributes are added to the field tag line on the form. Multiple attributes are separated with a comma, and each list ends with a semicolon. The list below shows attributes that can be used in a 4GL form.

AUTONEXT Advances the cursor to the next field without pressing

RETURN. Saves one keystroke. COLOR Specifies the video display of a field, optionally based on

logical conditions. COMMENTS Displays a message at the bottom or the screen (on line 23)

when the cursor moves into a field with this i attribute. The comment line is automatically erased when the cursor moves out of the field.

DEFAULT Assigns an initial possible value to a field to save keystrokes while adding data. The default values appear in the field only when the user is in add mode.

DOWNSHIFT Converts the field to lower case. { Controls the display format for fields containing DECIMAL,

SMALLFLOAT, FLOAT and DATE data | types.

INVISIBLE I

Available starting with version 4.1, it creates a password-type field, which allows data to be entered without it displaying to the screen.

INCLUDE Allows you-to specify acceptable values fora field, and causes 4GL to check these values before accepting an input value.

NOENTRY Specifies that no data entry to this field is permitted. J PICTURE Species the pattern for data entry into a character-type field.

REQUIRED I

Insists that a value be entered in a field. This attribute is enforced when you press ACCEPT to insert the whole row into\he table, not when you are typing data into the field.

Page 185: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

184

REVERSE Displays field contents in reverse video. UPSHIFT Converts the field to upper case. VERIFY Requires entry of identical data twice. WORDWRAP Makes available a multi-line editor which allocates entire

words to one display segment. INSTRUCTIONS This allows you to define screen records and arrays, and

also change the default delimiters. < Used to define screen records and screen arrays s Change the default delimiters for display fields

Delimiters The delimiters that 4GL uses to enclose fields when the form appears on the screen can be changed to any other printable character, including blank spaces. To change the delimiters from "[ ]" to another character, use the following syntax:

DELIMITERS "ab"

NOTE: Where a is the opening field delimiter and b is the closing field delimiter. Do not change the delimiters in the SCREEN section of the form.

Attribute Phrases Examples .

fool = customer.fname, comments = "Enter first name and midle initial"; aO = customer.state,

INCLUDE = ("MA", "NJ" , "VT" , "NY"), COMMENTS = "State must be MA. NJ, VT, or NY"; 04 = order_date, DEFAULT = TODAY; fOO8 =

phone, PICTURE = "###-###-####XXXXXX";_____________________ __

012 = ship_date, — FORMAT = "mm dd, yyyy";

Note: The equai sign, parentheses and quotes are important.

Compiling a Form Specification

Once you have modified the screen section to the desired appearance, the Programmer's environment presents you with the MODIFY FORM menu. These are three options available on this menu:

Page 186: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

185

Compile Translates the form specification file into a format that INFORMIX-4<3I. can use.

Save-and-exit Saves the changes you have made, but will not compile the form. Use this option when you have not finishing making changes, but want to come back to the form later.

Discard-and-exit Discards any changes you have made during your editing session. Use this option if you made destructive changes to your form and do not wish to save these changes.

In most cases, you will want to select the Compile option.

Correcting Errors If the compile process found errors in your form specification file, the Programmer's environment presents you with the COMPILE FORM menu. There are two options available on this menu:

Correct Takes you back into the editor and points out errors that were found during the compile phase.

Exit If you. choose not to correct the errors that were found, the

Programmer's Environment presents you with the MODIFY FORM menu. You can then select Save-and-exit to correct the errors-later, or Discard-and-exit to restore the form to its original state

Note: once you have corrected yours errors, you will go through the compile process again.

This statement is use to associate an INFORMIX-4GL form name with a previously compiled form.

The OPEN FORM statement associates a name with a compiled form. Each time the OPEN FORM statement is encountered, the compiled form is loaded into memory until you execute a CLOSE FORM statement. If you make changes to a form file, it is not necessary to recompile your INFORMIX-4GL code. Remember, the form and INFORMIX-4GL code are compiled separately. The OPEN FORM statement tells your program to retrieve the most recently compiled copy of your form.

The DISPLAY FORM Statement

Page 187: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

186

Syntax DISPLAY FORM form-name Example DISPLAY FORM custjorm

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

The DISPLAY FORM statement causes the named form to be displayed to the screen on the FORM line. FORM line is one of ; the parameters that can be changed in the OPTIONS section of an INFORMIX-4GL program. By default, it is line three of the current window or screen. The DISPLAY FORM statement is usually just before a MENU statement.

The CLOSE FORM Statement

Syntax DISPLAY FORM form-name

Example

DISPLAY 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.

FORMS & WINDOW

When you create a window in INFORMIX-4GL. you are actually creating a mini-screen. Once a WINDOW statement has been executed, statement, will take place in that window. There are two methods for using forms with windows.

You can determine how big the window is going to be and then Place the form in the window. To do this, you will have to: Open a window Make sure a form has been opened either, here or in a previous function. Display the form. Because the window statement came first, this form will be displayed in the window.

Second method is very easy by using open a window command with WITH FORM option.

OPEN WINDOW statement

Syntax: 1. OPEN WINDOW window-name AT row,column

WITH integer ROWS, integer COLUMNS • . [ ATTRIBUTE {attribute-list)}

2. OPEN WINDOW window-name AT row, column WITH FORM form-file . [ ATTRIBUTE (attribute-list)]

Page 188: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

187

Example: 1. OPEN WINDOW w_cust AT 3,3

WITH 15 rows, 75 columns ATTRIBUTE (BORDER)

2. OPEN WINDOW w_cust AT 3,3 WITH FORM "cust" ATTRIBUTE (BORDER)

ATTRIBUTE LIST: BORDER, COLOR, and REVERSE. In addition the location of ' the PROMPT LINE, MESSAGE LINE, FORM LINE and COMMENT LINE carrspecified for this window, without disabling the OPTIONS statement specifications for other windows. ^

The CLEAR Statement Syntax: CLEAR SCREEN

Clear screen causes a fresh screen to be drawn. Any form that has been opened can be displayed, or a new window can be opened. The Clear screen command clears away all open windows and makes the entire screen the current window.

CLEAR FORM __

All the values entered onto_a displayed form be cleared. The form itself remains but the Values in the field are cleared away.

CLEAR field-list This command causes the specified values entered onto a displayed form to be cleared.

CLEAR WINDOW window_name The named window to be cleared

The CURRENT WINDOW Statement

You can open as many windows as the memory on your system will allow. However only one window without clearing may be current at a time. To change the current window without cleaning or closing any previous window. Use then CURRENT WINDOW is window name statement.

In the example above the last window to be opened w2 is the current window issuing the current the CURRENT WINDOW IS w2 statement bring under laying the window to the foreground and puts the other window in the background.

The current window statement must be followed with a window name or the keyboard statement causes all window cause all the window to be sent the background and the entire screen become the current window.

Page 189: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

188

The CLOSE WINDOW Statement

Syntax CLOSE WINDOW window-name

Example CLOSE WINDOW w_cust

CLEAR WINDOW

The CLOSE WINDOW statement is used to release the memory associated with a window. If you want to the window in memory and clear from the screen to use later work then issue just the CLEAR SCREEN command. To bring back that window use CURRENT WINDOW IS statement to bring the window back. The SCREEN INTERACTION STATEMENTS

• Error • Message • Display • Prompt • Modifying default display characteristics for above statements using the OPTIONS

statement.

The Screen

The screen before using the screen interaction statements, it is necessary to define exactly what the screen is in INFORMIX-4GL. The screen is that area of the terminal where information can be displayed. By default, the area of the screen in INF0RMIX-4GL is 24 rows by 80 columns. INFORMIX-4GL allows you to break the screen area into smaller sections called windows.

The WINDOW Window means mini -screen, by reducing the area in which statements can be placed. In the example above if you tried to display a message on row 16 then you would get an error. Only one window or screen can be active at a time.

1. You can create as many as windows as you want. 2. Only one window is active at a time. 3. We can change the active window time to time 4. Last active window is current window. 5. The size of the window affects other INFORMIX-4GL statement.

The MESSAGE Statement

The message statement is use to display a character string on the message line. The default message line is line two of the active window. You can change this line by using the options statement.

The message is remain on the screen until another message statement is used or by giving some delay give blank message as given in example.

Page 190: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

189

MESSAGE "No more rows in that direction." SLEEP 3 MESSAGE

ATTRIBUTES: You can associate an attribute with the message statement. An attribute affects the way in which a MESSAGE will Be displayed. The following is a list of attributes that can be used with the MESSAGE statement.

UNDERLINE REVERSE INVISIBLE BOLD BLINK NORMAL DIM .

The difference between ERROR and MESSAGE statement

1. An error statement is always relative to the screen. A message statement is relative to a window.

2. The error statement always sounds the terminal bell. 3. Error statement is always appears at the bottom of the screen (we can change the

position by using the OPTION statement) message is appears any where in the screen by specifying the row & column.

The DISPLAY Statement

The display statement is used to display a character string to a specific location on the screen. This is different from the MESSAGE statement, which always starts in the left margin of the MESSAGE line. With displayed by giving a row and column location is specified, DISPLAY will display your message where the cursor is currently pointing. If the mention column row is not in the screen area the run-time error is occurs.

ATTRIBUTES: we can add an attribute with the DISPLAY statement. The following is a list of attributes

UNDERLINE REVERSE INVISIBLE BOLD BLINK NORMAL DIM

Syntax: DISPLAY "message" [AT row, column {ATTRIBUTE (ATTRIBUTE LIST)}] Example: DISPLAY "row added" AT 22,3 ATTRIBUTE(reverse)

The PROMPT Statement This is use not .only to display the character string but also waiting for user replay. The user replay is stored in the variable. The statements necessary for defining variables are covered later.

Page 191: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

190

Options Details

this option is used then system will wait for the single character entered and not waiting for the RETURN key to be pressed into the variable. Prompt "are you sure? Y/N" For CHAR answervar

e can associate a Help number with a prompt statement. A Help number will find the numbered message created using the mkmessage utility and display it to the user when the Help.key CONTROL-W by default) is pressed. The mkmessage utility is covered in next session.

is ON KEY option is used to define an action that will occur when the key listed in the key-list is pressed. Specific uses of the ON KEY clause is covered in next : session. : J

ATTRIBUTE: we can associate two sets of attributes with the PROMPT statement. The first attribute applies to the message; the second attribute is for the variable or user's response to the PROMPT statement.

UNDERLINE REVERSE INVISIBLE BOLD BLINK NORMAL DIM

The OPTIONS Statement

The option statement can be used to change default values associated with the some commands. Defaults that can be changed include:

1. The line error message are displayed on 2. The line message are displayed to

3. The help key 4. The location of user prompts 5. The location of menus

The options statement is used to modify the default values associated with some commands. For example, we can create on-line help in our program. By default, the help key is CONTROL-W. Listing a different help key in an OPTIONS statement as shown below can change this.

Page 192: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

191

You can have more than one OPTIONS statement in a program. Listed above are some aspects of your code that can be affected by options that you set.

The default lines on which these statements display can be changed using the OPTIONS statement.

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

(First is equal to line 1.)

Options Menu Line

The MENU LINE option is use to set the menu lines to any lines of your current screen or window. By default menus are assigned to the first two lines of the current screen or window. In the example given below change the position of the MAIN MENU at the bottom of the screen.

Either the reserve words, FIRST or LAST, can be used with MENU LINE. The values of FIRST or LAST are always relative with the current window or screen.

MAIN : CALL set_options()

CALL main_menu() CLEAR SCREEN END MAIN

. FUNCTION set_options() OPTIONS MENU LINE LAST - 1 END

FUNCTION

Creating a HELP File: The mkmessage Utility

This utility is used to create the customized on-line help messages for an application. This utility is executed from the operating system; this compiles a text file of help messages into a file which is executable by an INFORMIX-4GL program.

To use mkmessage, you first create a text file of Help messages. This file can be created using any system editor.

The illustration above has a text message file called custhelp.msg. From the command line this file is being compiled into custhelp.ex. This is the file that INFORMIX-4GL will recognize as a Help file.

1. To add a row to the database, type the information about the customer into the spaces between the brackets, which are called fields.

2. To search the database for information about a particular customer, type the customer's last name.

Page 193: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

192

Text file: custhelp.msg

$ mkmessage custhelp.msg custhelp.ex

The help file is a text file containing numbered messages that you can use with the MENU, INPUT, INPUT ARRAY and PROMPT statements. The Help file shown above, for example, contains help messages for the menu options which might appear on a customer menu.

This file contains a series of messages, separated by lines that contains only a period and a message number The Help file must always have this format, to create a Help file, follow the following rules

1. Use a text editor to create a file that stores Help messages. You may choose any name for the help file. You may want to give the file an extension like msg so that you can identify it easily.

2. Type the text for the Help file using the format shown above. Make sure you type a period followed by a message number on a separate line, and then type the message below it. You do not have to enter messages in any specific numerical order, but you must make sure that each message has a unique number.

3. Save the file when you are finished entering the help messages. 4. Run the mkmessage utility, which is described in below example.

Syntax: mkmessage filenamel filename2 example. mkmessage custhelp.msg custhelp.ex

Specifying a Help file and Key

• The OPTIONS statement provides two optional clauses for setting up help within a program. They are described below: HELP FILE filename specifies the path name of the Help file. If filename is not in the current directory, make sure that you designate the full path name of the compiled Help File after the Help file keywords.

HELP KEY, where help-key is a function or CONTROL key. To designate a function key as the Help key, type Fn, where n is the number of the function key. CONTROL keys are designated with the format CONTROL-X, Where X is a letter key to be pressed along with the CONTROL key.

The default control Help key is CONTROL-W. You cannot use the following keys in the HELP KEY clause of the OPTIONS statement:

INTERRUPT . CONTROL-H CONTROL-D CONTROL-X CONTROL-A CONTROL-R CONTROL-L ESXAPE CONTROL-M CONTROL-S CONTROL-Z CONTROL-Q

Page 194: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

193

FUNCTION set_options() OPTIONS MESSAGE LINE LAST-2, PROMPT LINE FIRST+2, HELP FILE "custheip.ex", HELP KEY CONTROL-B

END FUNCTION

FUNCTION cust_menu() MENU "CUSTOMER11

COMMAND "Query" "Search for a customer." HELP 1

COMMAND "Add" "Add a new customer." HELP 2

END MENU END FUNCTION Here help file is specified in the OPTIONS statement, the messages in the Help file can be used. In a MENU statement, each command on a menu can have a help message associated with it. If the user were to press the Help key with the Query option highlighted, the message associated with number one in the Help file would be displayed automatically in the help menu format.

Help is not displayed automatically. A user must press the Help key. The Help number will only be used if the user presses the Help key.

We can add help messages in a prompt statement by using the HELP# syntax. In the example above, if the users press the Help key while .they are being prompted, then the message associated with number 100 will be displayed in the help menu format.

The HELP menu

When help is required by an end user, the Help file is read to get the Help message that corresponds to the number in your INFORMIX-4GL program. The message is then displayed with the menu structure shown below

If the lines in the help file are more than 20 then automatically divided into the pages and screen option is appears. User can come out from the screen any time by pressing Resume button.

HELP: Screen Resume Ends this Help session.

The information entered in the help file would be presented here in exactly the same format as it was entered. If there is more than one page, the Screen option will be highlighted; if not, then Resume will be highlighted.

Page 195: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

194

DATA TYPES, OPERATORS AND FUNCTIONS

The data types are available in INFORMIX-4GL are part of the basic set of data types that Informix engines support. Those were introduced in SQL A summary of those basic data types is included in table given below.

Sr. No Types of Structure 1. char (n) 2. character (n) 3. dec (precision, scale) 4. decimal (precision, scale) 5. double precision (float precision) 6. float (float precision) 7. int 8. integer 9. money (precision, scale) 10. numeric (precision, scale) 11. real 12. serial (starting num.ber) 13. smallflat 14. smallint 15. date 16. datetime <largest> to <smallest> <fraction precision> 17. interval <largest> to <smallest><fraction precision> 18. byte in <tablespace or blobspace> 19. text in <tablespace or blobspace> 20. varchar (<maximum length>, <reserve length>)

INFORMIX-4GL offers two additional data types that are unique to 4GL. The declaration and definition of all data types is covered in detail in the next section. These additional Informix -4GL only data types are listed here to complete the list of . available data types in INFORMIX-4GL.

21. record {[like <tabname>.*] [[<varname> like <tabname>.<colnarhe>,....] [<varname> <datatype>,...]]} end record

22. arrayT<integer count>[ ,<integer count>[,<integer count>]]']" of non-array datatype>

Page 196: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

195

Operators

INFROMIX-4GL supports that are also valid in SQL, such as those shown in Table below

Operator Function Description

Mathematical Operators

+ Unary plus and addition Unary minus and subtraction Multiplication

/ Division

Relational Operators

< Less than' <= Less Than & Equal To > Greater than >= Greater Than & Equal To = Equal <> Not equal != Not equal [not] between. Inclusive range

Boolean Operators

not unary (opposite result) and Conditional and (both condition must be true) or Conditional or_(one of both condition must be true)

String Operators

|| Concatonation matches Pattern matching Like Pattern matching

Set Operators [not] in Value contained (or not) in list [not] exists True if at least one row is returned by subquery all True if all values returned by subquery are True, any True if any values returned by subquery are True some True if some values returned by subquery are True.

Null Operator is [not] null True if the argument is not null.

Page 197: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

196

In addition, lnformix-4GL also supports some operators that are not available in SQL. These are listed in Table below.

Operator Function Description

Exponentation mod Modulus (division remainder

Concatenate string. clipped Clip trailing blanks from a string. Using Format data for display or report purposes.

Formatting with the using operator allows you to display dates and numbers in the format you specify. For date values, the using clause uses the string identified in table below

String Result in a display of dd Day of the month from 1 to 31. ddd Day of the week: Sun, Mon ............ mm Month of the year from 1 to 12 mmm Month of the year: Jan, Feb. .......... yy Two-digit year yyyy Four-digit year

. let p_date = "4/15/97" let p_resu!t = p_date using "ddd, mmm, dd, yyyy"

using is used extensively in reporting and display statements. To format numbers, the using clause uses the string identified liable below

Sr. String Result in a Display of

1. # Number of blank 2. & Number or Zero 3. * Number or asterisk 4. . < Let justify and remove trailing blanks 5. , display a comma if there is a number to the left. > 6. . Display a period. 7. - Display a minus if the is negative. 8. + Display a plus or a minus for the value 9. () Display parentheses around a negative value 10. $ Display the dollar sign.

Page 198: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

197

General-Purpose Library Functions

Informix-4GL provides functions that can be called from C programs, but those are not covered here. The functions that can be called within a 4GL program are listed in bold below, followed by a brief description of their functionality.

Arg_val ( <integer expression> )

Returns the argument in position <integer expression> from the command line. The argument in position zero is the name itself. The value in <integer expression> must be between 0 and

num_args(), the count of arguments.

Ar_count() Returns the number of records entered into a program array.

arr_curr() Returns the number of the program array row that the cursor is on when entering or displaying arays.

Ascii (<integer number>) Converts the <integer number> argument into its corresponding ASCII character.

<character variable or text string> clipped removes trailing blanks from a character variable.

Current [ <large datetime value> to. <smaller datetime value>] Returns the system date and time in the precision defined by its arguments.

Date Returns a string with the system date, by default, in the"' — — following format: weekday, month, day year. This default format can be changed with the using clause.

Date (<date expression>) Extracts the day of the -month from a date corita1necHrt-<date—-expression> and returns it as an integer value.

Downshift (<character string> | <character variable>) . Returns a string with all uppercase characters in its argument replaced by lowercase characters.

Page 199: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

198

Err_get (<integer expression>) Returns a character string that contains the description for the error message in the argument <integer expressions

Err_print (<integer expression^) Displays in the error line the description for the error message in the argument <integer expressions

Err_quit (<integer expression>) Displays in the error line the description for the error message in the argument (<integer expression^ and terminates the program.

Errorlog (<character string> | <character variable>) Places the contents of its argument in the error log file for this program.

Extend ( <date expression> | <datetime expression^ [, <larger datetime valu.e> to-<smaller datetime value> ])

returns a datetime expression equivalent to the date or datetime argument with the precision specified.

Fgl_gerenv ( <character string> | <character variable>) Returns a character string with the contents of the environment variable in its argument.

Fgi_kerval ( <special key character strihg> ) Retuinsthe integer value of the key specified in its argument. It is used in connection with fgl_lastkey().

Fgijaslkey () Returns the integer value of the last key the user pressed.

Field_touched ((<name of a screen frprr. f!Gld>} [,...]) | <name of screen records* |

<name of a screen array>.*) returns true if any of the field on a screen have been altered; otherwise, it returns False. The function filters out keystrokes that do not alter the contents of the field visited.

Get_fldbuf ({<name of a screen field>} [,... ] | <name of a screen record>. * | <name of a screen array>.*)

returns a string with the contents of the specified arguments.

Infield {<name of a screen from field>} [,...] | <name of a screen record>.* | <name of a screen array>.*)

returns true if the cursor is currently on the field indicated by the argument.11

Page 200: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

199

Length ( <character string> | <character variable> ) Returns the number of character in the argument.

Mdy ( <month number>, <day number>, <year number>) Returns a date value created with the integer arguments.

Month (<date expression?-) Extracts the month from a date contained in <date expression> and returns it as. an integer value.

Num_args () Returns the number of command-line arguments used when invoking the program.

Scr_line() Returns the number of the screen array row that the cursor is on when entering or displaying arrays.

Set_count (<integer expression>) Specifies that <integer expression> is the number of rows that have been loaded into a program arrays.

Showhelp (<help number>) Displays a message in the help line whose contents are those of the item <he]p number> in the current help file.

Startlog ( <error log file name> | <error log.file pathname> ) Opens (and creates if necessary) an error log file named in its argument.

Time Returns a character string with the current reading of the system clock.

Today Returns a date value with the current system date.

<numeric expression> units <datetime unit> returns an interval data type with the value of <numeric expression> converted to the unit of measure represented in <datetime unit>.

Upshift ( <character string> | <character variable> ) Returns a string with all lowercase characters in its arument replaced by uppercase characters.

{ <numeric expression> | <date expression>} using "<format string>" formats the numeric or date expression as specified by the <format string>. Details are given in above table (Numeric formatting).

Weekday ( <date expression> | <datetime expression> ) Returns a number that indicates the day of the week for its argument. Sunday is represented by 0, Monday by 1, and so on.

Page 201: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

200

Year ( <date expression> ) Extracts the year from a date contained in <date expression> and returns it as an integer value.

DELAYS To hold the execution of a program for a certain number of \ seconds, use the sleep statement as follows:

Sleep <seconds> Testing and Looping

INFORMIX -4GL offers types of conditional tests (if and case statements) and two types of standard loops (for and while loops). (INFORMIX -GL also offers the combination go to and label to manage to flow of control, but its discussion is omitted.) These operate like their counterparts in other programming languages.

The if and case statement blocks are the standard conditional two-way or multiple branching blocks. The syntax of these statements is as follows:

lf<Boolean expression> then <4GL statements> else <4GL statements>

end if

- - . _ case [ (<expression>)] ,• when <expression> {4GL statements>: exit case} [....... ]

[...] [otherwise

{,4GL statements>: exit case} [,....] ] end case

The syntax for the unconditional for loop is as follows :

for <integeLvariahlp >.i=^'^e^inningTme^ef^>Jcrjressiqn>_ to <endirig integer expressions

[ step < integer increment > ] { <4GL statements > :

continue for: exit for} end for

The for statement block is executed starting at the value < beginning integer expression> as long as the <integer variable> is less than or equal to the <ending integer expressions. Each iteration through the loop increases the < integer variable> by the amount specified in the step < integer increment clause. The statements continue for and exit for within the body of the statement block provide for further flow of control; if the continue for statement is reached, the program returns to the for statement, bypassing all the statements after the continue for. If the exit for statement is reached, control flows to the statement following the end for statement.

Page 202: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

201

The syntax for the conditional while loop is as follows: while <Boolean expression>

{<%4GL statement^ " continue while|

exit while} end while

The while statement block is executed as long as lf<Boolean expression> evaluates to true. The statements continue while and exit within the body of he statement block provide for further flow of control; if the $ continue while statement is reached, the program returns is to the while statement, bypassing all statements after the continue while. If the exit while statement is reached, control flows to the statement-following the end while statement “T”.

System variables The INFORMlX*4erprogramming language provides two system-wide variables to direct termination conditions within a program. The lnt_flag variables is set to true if the user presses the interrupt key- by default, the Delete key. The quit_flag variable is set to true if the user presses the quit key- by default, CtrH\. The interrupt-key can be redefined in the options statement.

In addition to the system variables discussed, INF0RMIX-4GL also offers three system-wide constants: false with an integer value of zero, true with an integer value of one, and not found with a value of 100. You can use these values in regular expressions. Error Handling By default, INF0RMIX-4GL terminates a program's execution with it encounters an error and displays a message to the terminal screen but not record the reasons for this termination anywhere. This is the lowest common denominator for handling errors in INFORMIX-4GL. One step up from doing nothing is error logging. If the developer implements error logging, an error still terminates the program's execution, but the cause of the error and the source code module location where the program aborted is recorded in the error log file. Each error, the location of the error, and the error code and description of the error. Here is a sample error log file:

Date: 10/23/1996 Time: 10:19:10 Program error at "update.4gl", line number 11. SQL statement error number -201. A syntax error has occurred.

A higher level of error management is also provided. Using the whenever error statement, the program is not terminated when an error occurs but rather transfers control to a developer provided error-handling routine. ERROR MANAGEMENT Error in INFORMIX-4GL programs crop up at various stages Syntactical errors in screens forms and source code modules are trapped and reported by the compiler. The only exception forms to this rule is for prepared statements that are not interpreted by the compiler but are passed to the engine for validation and execution at runtime. Errors that occur at runtime are SQL errors or program execution 4fil- errors. In you sample programs you have already been addressing some of the-error management features that INFORMIX-4GL offers. This section formalizes their use and introduces new error management features.

Page 203: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

202

TRAPPING ERRORS

By default, when INFORMIX-4GL encounters a fatal error during execution, it halts execution of the program and returns control to the command line. In this exit process, it reports the error number and description, as well as the line of the program that failed to the terminal screen where the user may or may not have time to review it.

To alter this behavior, use the whenever error statement. This statement tends to be used as a wrapper for the sections of code that you want to handle in a way other than the default. The whenever error statement is a compiler directive rather than a command in INF0RMIX-4GL It operates in the source code module where it is defined, and only from the point at which it is defined, its behavior continues until either the source code module ends or the compiler encounters another whenever error statement. These are the reasons for using it as a wrapper for the sections of code you want to handle your own way. The syntax for this command is, as follows:

Whenever { [any]error

sqlerror warning sqlwaming not found

} {call <error handling function> continue stop }

The any clause in the whenever error command strengthens the behavior of the detection:

Whenever error traps database and screen interaction errors; whenever any error traps those errors and, in addition, errors in the execution of any 4GI expression.

Typical examples of this; command are whenever error Call error handler whenever not found continue

the whenever error call error_handler clause is typically used at the top of every source code module, so that you can manage the error trapping within a central function named error handler, whenever not found continue is placed before a select statement so that you can handle the return of no rows locally. GENERIC ERROR MANAGEMENT

In the example, you used two of the error management tools that INFORMIX-4GL provides. You have used the status variable to detect SQL errors and not found conditions, and you have also used the startlog function to record in an ASCII file the runtime errors encountered.

In addition, you have displayed SQL errors within an error window that forces the user to take notice before the program terminates. Actually, for these to work, you to include a whenever error continue command at the top of each of the source code modules in the program. Otherwise, an error will still terminate the program without ever reaching the call to the error_display function. Try the program with and without the whenever error clause and verify the behavior described.

Page 204: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

203

To go beyond what you have already done, you would define your own function to manage errors trapped during execution. If, instead of the clause whenever error continue in your source code modules, you use the whenever error call error _ handler, INFORMIX- 4GL will call the function error _ handler whenever it encounters as error and, upon entry into the function, the values of status and SQLCA will still reflect the engine's errorecorded parameters for the statement that caused the error.

The function error handler could simply use the errorlog, err print, or err_qu. functions, or it could use the status and SQLAC variables to add some logic to the program's execution. The INPUT Statement

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

• Inputting information into program variables • inserting the data in those program variable into the database

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

• Initializes 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 DEFAULT attribute 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 leaves each field. • Waits for a signal from the users that they have finished their • data entry.

Before using the INPTU statement you must satisfy the following condition:

• There must be a form open and displayed • There must be a program variable assigned to each field in

which you are going to allow data entry.

INPUT PROGRAM VARIABLE

Syntax-- INPUT- program-variable list field FROM list

Example

DATEBASE stores___ GLOBALS

DEFINE gr_customer RECORD LIKE customer.* END GLOBALS

Page 205: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

204

ATTRIBUTES f000 customer.fname, f001 customer.lname, f002 customer.company, f 003 customer.address1 f 004 customer.address2, f 005 customer.city, f 006 customer.state, f 007 customer.zipcode, f 008 customer.phone

INPUT . gr_customer.fname, gr_customer,. name, gr_cusfomer.company, gr_customer.address1 gr_customer.address2, gr_customer.city, gr_customer.state, gr_customer.zipcode, gr_customer.phone

FROM fname, lname, company, address1, address2, city, state, zipcode, phone

The program variables listed have been defined in an INFORMIX-4GL module, and field list 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.

In the above example it is clearly written the sequence of entering values in the field in which cursor will move.

It is also possible to control the entering data in particular field. For example if you want to enter the data in only, the fname, lname and company fields. Rather man defines another program record that contains just these three fields, you should use the following syntax:

USING THE SQLCA RECORD AND ITS COMPONENTS

Consider the following section of code for a generic handling function:

funct ion error_handler() define em char (70), Pj_sqlcode integer

whenever error stop

let p_sqlcode = SQLCA.sqlcode let int_flag = false

case (p_sqlcode) when 0 exit case when notfound call error_display (w Row Not Found")

when -206

Page 206: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

205

call error_display ("Table doesn't exist; exiting program ") exit program

when -242 call error_display ("Table locked by another user; baili4ig~pg*") exit program

otherwise - let em = "Error: ", p_sqlcode using w <<<<<<<<<<",

"; can't decide what to do. Ask.for help!" call error_display(em) exit program end case

INPUT gr-custotner. fname, gr_customer. lname, gr_customer.company

FROM fname, lname, company

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.

There are three ways for the end user to come out from the INPUT statement:

• By accepting value in the last field of INPUT statement and pressing RETURN key the control is transfer to the program.

• Secondly if the user presses the ACCEPT key (ESC by default), the program will continue to the next line of code.

• Third method is to press the INTERRUPT key.

The OPTIONS Statement Changing the Defaults

Syntax: OPTIONS

ACCEPT KEY key-name, INPUT WRAP Example: • OPTIONS

ACCEPT KEY CONTROL-E, INPTU WRAP

If you do not want the ESC key to be the ACCEPT key, you can change it in the OPTIONS statement -the example above. The ACCEPT key has been changed to CONTROL-E.

INPUT WRAP The default condition of exiting from the INPUT statement is by pressing RETURN key in the last field. If by mystically is user entered wrong data in the last field then he cannot update that data. But this default condition can be turned off by including the INPUT WRAP statement in the options section of your program. This will take back your cursor to wrap back to the first field, instead of automatically exiting after the last field in the INPUT statement.

Page 207: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

206

The INPUT BY NAME statement

Example: INPUT BY NAME gr_customer.*

Program Variables

DATABASE stores

GLOBALS DEFINE gr_customer

RECORD LIKE customer.* END GLOBALS

The program-variable is a record that has been defined in an 1NFORMIX-4GL module. Using the syntax shown in the above example requires that the names of the variables defined in the gr_customer record must be the same as those in the field list of the form. The cursor will go through the fields based on the • order of the DEFINE statement for the program variables. In the example shown above, this would be in the same order of the table's customers when the customer table was built.

The INPUT Statement: BY NAME With THRU Example: DATABASE stores

GLOBALS DEFINE gr_customer RECORD LIKE customer

END GLOBALS

MAIN— INPUT BY NAME gr_customer.fname

THRU gr_custpmer.phone END MAIN - .

Using the syntax shown above requires that the names of the variables defined in the gr__customer record must be the same as those in the field list of the form. This method of using INPUT allow you to enter specific fields while still using the BY NAME syntax..

NOTE: INFORMIX-4GL looks at the form field name to determine whether a variable name matches a field name.

Page 208: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

207

INPUT Statement Clauses

Syntax INPUT {BY NAME VARIABLE -LIST [WITHOUT DEFAULTS VARIABLE-LIST

[WITHOUT DEFAULTS] FROM {FIELDMJST | SCREEN-RECORD [{N}].*} [ATTRIBUTE

(ATTRIBUTE-LIST)] [HELP (HELP NUMBER)]

{ .

{BEFORE INPUT

AFTER INPUT

BEFORE FIELD FIELD-LIST

AFTER FIELD FIELD-LIST

ON KEY (KEY-LIST).

The syntax for the INPUT statement-allows the use of clauses. The clauses can be used to perform a specific time. The available clauses are listed below. . *

ATTRIBUTE This is an optional keyword yoircan use to specify screen input attributes. The attribute-listjs a. list, in parentheses, of one or more screen input attributes, separated by commas.

Help this is used to specify a help number message The help message is generic to the INPUT statement. The message associated with the help number should apply to the INPUT statement as a whole, rather than a specific field.

Before input the before input clause is executed before the control of the program is turned over to the end user.

AFTER INPUT AFTER INPUT transfers control to an INFORMIX-4GL statement after the user has finished entering information. The statements following the keyword will execute if the user presses the ACCEPT key or the INTERRUPT key.

BEFORE FIELD The BEFORE FIELD clause transfers the control to an INFORMIX-4GL statement when the cursor enters the specified field.

Page 209: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

208

AFTER FIELD The after field clause transfers control to an INF0RMIX-4GL statement when the cursor leaves the specified field.

ON KEY The ON KEY clause transfers control to an INFORMIX-4GL statement when a user presses the key or key sequence listed in the (key list).

NEXT FIELD NEXT FIELD (field name) causes INFORMIX-4GL to move the cursor immediately to the specified field. This statement is used to bypass the natural cursor movement of the INPUT statement. Keywords, NEXT and PREVIOUS, are valid in the NEXT FIELD statement starting with the 4.1 release. NEXT and PREVIOUS can be used instead of naming the fields explicitly in the NEXT FIELD statement.

To move the screen cursor one field forward or backward from its current position, you can simply specify:

NEXT FIELD NEXT or NEXT FIELD PREVIOUS

CONTINUE INPUT The CONTINUE INPUT clause skips all subsequent that may appear in the current clause of the INPUT statement and returns the cursor in the screen from at the last screen field occupied.

EXIT INPUT The EXIT INPUT clause causes INFORMIX-4GL to leave the input statement immediately.

END INPUT The ENDINPUT clause terminates the INPUT statement. This statement is required if any of the clauses are used. The END INPUT statement cannot be used if there were no clauses used.

INSERT STATEMENT

SYNTAX

INSERT INTO (TABLE NAME) [(COLUMN-LIST)] VALUES (VALUES LIST)

EXAMPLE

INSERT INTO CUSTOMER (CUSTOMER_NUM, FNAME, LNAME) VALUES (0, GR_CUSTOMER.*)

INSERT INTO CUSTOMER (CUST.OMER_NUM, FNAME, LNAME) VALUES (0, GR_CUSTOMER.FNAME, FNAME, GR_CUSTOMER.LNAME)

Page 210: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

209

The INSERT statement is used to place the values stored in program variables into the column of a database table. If the column list is omitted, it is implied that one value will be supplied for every column in the specified table. If a column list is specified but not all columns in the table are listed, then a NULL value will be inserted into

the omitted columns. Serial columns If a table contains a column which was assigned the data type of SERIAL, the

program variable for that column must be set to zero for the proper number to be assigned.

The SQLCA Record SQLCA stands for Structured Query' Language Communication access. It is a pre-defined record that comes with the INFORMIX-4GL product. The SQLCA record resides in memory and is used to communicate with the database regarding the status of statements as they execute. The SQLCA record contains:

> Information about the most recently run statement > Warning about what may happen or what has happened

You will access pieces of the SQLCA record to do error checking in your program.

Page 211: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

210

Definition of SQLCA The SQLCA record has been pre-defined for you. Its definition looks like this:

DEFINE SQLCA RECORD SQLCODE INTEGER

SQLERRM CHAR (71) SQLERRP CHAR(8)

SQLERRD ARRAY[6] OF INTEGER, SQLAWARN CHAR(8)

END RECORD

As its name implies, SQLCA is a global, pre-defined, record variable, it consists of ten individual variables hat hold information about INFORMIX-4GL statements as they execute. • You do not need to include a DEFINE statement; the SQLCA record has already been defined for you. What type of variable are use in the SQLCA record are given above. the parts of SQLCA

SQLCA.SQLCODE = Status of an SQL statement

SQLERRM = Arguments for error messages. SQLERRP , = Not used at this time.

SQLCA.SQLERRD[1] " = Not used at this time. SQLCA.SQLERRD[2]___ = Serial value assigned to a column. SQLCA.SQL£RRt>{3] .= Number of rows processed. SQLCA.SQLERRD[4] = Estimated CPU cost or a query. SQLCA.SQLERRD[5] = Offset of error in an SQL statement. SQLCA.SQLERRDJ6] = ROWID of the last row. •

The Parts Of SQLCA

The SQLCA record consists of 10 separate variables. SQLERRP and SQLERRD[1] are not used at this time. Each of the other variables is used for a specific purpose.

SQLCA.SQLCODE

SQLCA.SQLCODE is set to a value after the execution of an SQL statement. There are three possible values for SQLCODE > A 0 (zero) in this variable means that the SQL statement

executed successfully. > Any value < 0 (less than zero) indicates that an error occurred during the

execution of an SQL statement. > A value of 100 is a special value used when a SELECT

statement did not find any rows.

Page 212: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

211

SQLCA.SQLERRD[2]

When you insert a 0 (Zero) into a SERIAL column, ISAM automatically assigns the next number in sequence. The number that is assigned is stored in this variable. The other portions of the SQLCA record are not commonly used in an INFORMIX-4GL program.

Note There is an INFORMIX-4GL keyword named NOTFOUND that equals 100. To make your code easier to read, you can use this keyword in place of 100.

The Global Variable Status

STATUS SQLCA.SQLCODEINSERT INSERT UPDATE UPDATE SELECT SELECT DELETE DELETE OPEN FORM

There is another global variable 'available to7ou.called status. The status variable is set to the same values that are available for SQLCA.SQLCODE.

The variable status is set equal to SQLCA.SQLCODE after all SQL statements. The difference is that status also' describes the success or failure of other INFORMIX-4GL statements, such as opening a form for display. For example, if the form you are requesting has been removed or cannot otherwise be found, then status would receive a value of < 0 (less than zero).

The SQLWARN variable

The SQLWARN variable is a string of eight characters whose individual positions signal various warning conditions (as opposed to errors) following the execution of an SQL statement. The characters are blank if no problems were detected. SQLWARN [1] is set to W if one or more of the other warning characters has been set to W. if this position is blank, you do not have to check the remaining warning characters.

SQLWARN [2] is set to W in the following conditions: 1. When one or more data items was truncated to fit into a CHAR

program variable. 2. When a database statement selected a database with

transactions.

SQLWARN [3] is set to W if an aggregate function (SUM, AVG, MAX OR MIN) encountered a NULL value in its evaluation.

SQLWARN [4] is set to W in the following condition: 1. When the number of items in the select-list of a SELECT clause

is not the same as the number of program variables in the

Page 213: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

212

INTO clause. The number of values returned by INFORMIX-4GL is the smaller of these two numbers.

2. When a DATABASE statement references an INFORMIX-On Line database.

SQLWARN [5] is set to W float-to-decimal conversion is used. SQLWARN [6] is set to W when your program executes an INFORMIX-4GL extension to ANSI standard syntax.

SQLWARN [7-8] are not used at the present time. Trapping Errors with the WHENEVER Statement

What is a Cusrsor?

Cursor is a marker that points to a row retrieved by a select statement. In its simplest form, a cursor is a pointer. It points to a row, called the current row; called the active set. There are many statements that deal with the manipulation of cursors. A cursor must be declared to retrieve rows that satisfy the criteria of multi-row select statement. The cursor is needed to pass the selected data to the program one row at a time. Whiteout a cursor, a select statement in an informix-4gl program anticipates only one row being returned to the front end.

Types of cursors There are three types o cursors available in informix-4gl. Each cursor has its own unique set of characteristics. The three cursors are

=> Scroll => Non-scroll => For update

The difference in the. types of cursors has to do with how the cursor (pointer) can be manipulated in the set of rows, and how the rows are affected when a cursor is moved through a set of rows.

1. Scroll cursor The scroll cursor can be used to access a set of rows. A scroll cursor points at one row at a time. Using a scroll cursor, you can move through a set of rows in either a backward or forward direction. Being able to move back through a set of rows to point at rows you have already pointed at is the scroll cursor's key feature. Other cursors only move forward through an active set of rows. In order to allow the cursor to move in a backward direction, the scroll cursor must retrieve a list of rows that satisfy the select statement (a cursor is based on a select statement) rit does this by creating a temporary table consisting of a snapshot of the appropriate rows. Once this snapshot is created, it will not include any changes to the rows by other users as long as you are looking at them.

A scroll cursor is most often used when a user has queried for a set of rows through a form. The scroll cursor enables users to brows through a set of rows, most commonly using menu options such as next and previous.

Page 214: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

213

2. Non-scrollong cursor

A non-scrolling cursor, as its name implies, will only go down (next) in the list of active rows. This type of cursor is used when you do not need to move back and forth within the active set, but you simply want to look at the rows in the order in which they were retrieved. A non-scrolling cursor is most commonly associated with a report.

3. For update cursor

A. for update cursor (also called a locking cursor) is similar to a non-scrolling cursor in that it can only retrieve the rows in a forward direction. However, a for update cursor will place a lock on the row that the cursor is pointing to and hold that lock until the next row becomes the current row. This is use for update and delete statements. You do not want other users deleting or changing the row you are using. It can be used in conjunction with the other types of cursors. For example we can use a scroll cursor to browse the rows, and . when you find-the row that you want to change, use a for update cursor to lock the row during your change.

Scope of cursors

There are also three types of scope. These cart be broken down like this.

Global or program Elements is known throughout all modules and functions. Module Elements is known to all functions within the module in which the element was defined or declared.

Local or function Element is known only to the function in which it is defined or declared;

Scroll Used to browse multiple rows

Non-scroll Commonly found in ail irifbrmix-4gl report.

For update Locks a row when touched.

Transactions in informix-4gl

What is a transaction?

A transaction is a set of actions that are executed as a group. If any of the actions cannot be completed, all other actions must be undone. A transaction always has a beginning and an end. The database server guarantees that operations performed within the bounds of a transaction will either be completely and perfectly committed to disk, or if that is not possible, the database will be restored to the state it was in before the transaction stated. Many things, such as a hardware or software failure, can make a transaction fail. Because of this, the database server must have a way to track all of the changes made during a transaction. This is done in the transaction log. The server uses the transaction log to record each change that it makes to the database during a transaction. If for any reason the transaction cannot be completed, the server automatically uses the data in the transaction log to reverse the changes.

Page 215: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

214

Database do not have transaction logging automatically. The database administrator must decide whether to create a database with transaction logging. If a database does not have logging, transactions are not available.

Specifying transactions -

SQL statement s are used to specify the boundaries of a transaction. You use the begin work statement to specify the start of a multi statement transaction. And the commit work statement to specify the end of a transaction. When the database server reaches

A commit work statement. It makes sure that all modification have been completed and properly committed to disk. If any external failure prevents the trans faction from being completed, the partial transaction will be rolled back when the system is restarted

Rollback work

In some cases, you will want to have your program cancel a transaction deliberately if certain circumstances occur. Use the rollback work statement to do this. The rollback work statement causes the database server to cancel the current transaction and undo any changes that have been made.

Qursor statements

Declare the declare statement is used to associate a cursor name with a select statement/The keyword scroll s used so that you can move the cursor in any direction. The withhold is optional syntax to prevents the cursor from being closed when a transaction completes. Unless you include the with hold keywords, informix-4gl closes the cursor when the transaction is terminated with either a rollback or commit work statement. You must explicitly close a cursor with hold.

syntax . declare cursor-name scroll cursor

[with hold] for select statement. example :

declare cust_pt.r scroll cursor for select * from customer

Open ' The open statement does the following checks the validity of table and column names from the select statement

. - is there a table called customer? - are the columns that you are selecting in this table? - do you have permission to do what you want to do?

In determining the active set, the open statement examines the select statement, and determines the optimum path for retrieving the rows requested. The open statement does not retrieve rows. The using variable list is used if the cursor expects user-supplied search variables.

Page 216: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

215

syntax open cursor-name [usiKS variable-list]

example ; ~ declare cust_ptr scroll cursor for select * from customer open custjptr

Fetch The fetch statement retrieves a row and puts its values into the program variables specified in into the clause.

A scroll cursor uses a temporary table when fetching rows from the database. As you will see, this allows a ser to fetch in both a forward and backward direction when a scroll cursor.

syntax fetch [next|{previous|prior}

|last|current|relative m |absolute n] cursor-name [into program variable]

example fetch cust_ptr into gr_customer.*

fetching with a scroll cursor •

The scroll cursor gives you the ability to move around in the active set of the cursor. Using one of keywords with the fetch statement will move you to the appropriate location in the active set.

First Fetch First moves the cursor to the top of the active set. the first row is determined by your select statement (order by clause).

Prior/Previous Fetch Prior/Previous will move the cursor from the current row to the row just before the current row. The keyword prior/previous are interchangeable.

Next Fetch next moves the cursor from the current row, down one, to

the next row in the active set.

Last Fetch last moves the cursor to the bottom row in. the active set.

Current . Fetch current indicates the current row of the active set;

In addition to next, previous, first and last there are two additional keywords, that can be used with the fetch statement and a scroll cursor.

Fetch Absolute # Fetch absolute followed by a number looks at the active list of - rows and will move to the absolute # from the top of the active list.

Fetch Relative # Fetch relative # moves # of rows from the cursor's current position.

Note : You can use negative numbers with a fetch relative bit not with a fetch absolute. " -

Page 217: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

216

Close The close statement deactivates the active set. After you close a select cursor, you cannot execute a fetch statement until you reopen the cursor. The close statement must be physically located after declare the, open and fetch statements.

syntax close cursor-name Example declare cust_ptr scroll cursor for select * from customer open cust_ptr fetch cust_ptr into gr_customer.* close cust_ptr free cust_ptr

Free In large application, it is possible to run out of memory resources needed for cursors. The free statement can be used to release the memory associated with cursor.

Coding with cursors

The code above contains the fetch-cust function, which is called when either the next or previous menu option is executed.

Notice that the next and previous options are not available for the user until the Query options has been executed successfully. The menu statement that would allow the user to select next or previous to call fetch_cust is listed below:

CURSOR SUMMARY

1. SCROLL cursor

=> Temporary Table is always created

=> SELECT is passed and optimized on the OPEN statement unless the statement is prepared.

=> Rows are read into the temp table as they are encountered and then passed to the data buffer.

=> FETCH NEXT retneves a buffer full of rows from the temp table. => All other fetches

retneve one row at a time from the temp table.

==> FETCH FIRST, LAST, NEXT, PREVIUS, RELATIVE and ABSOLUTE are allowed.

Page 218: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

217

2. NON-SCROLLING cursor

=> Same as a Scrolling cursor with the following exceptions

=> Temporary tables is only created when the optimize query plan determines the need for a temporary table, e.g. ORDER BY on a non-indexed column.

=> Only a FETCH NEXT is allowed.

3. FOR UPDATE cursor

=> Same as a Non Scrolling cursor with the following steps

=> With each FETCH, the current row is locked and the previous row is unlocked. .

=> FOR UPDATE never creates a temp table.

Page 219: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

218

The PREPARE statement translates a character string into an SQL statement that the engine can understand. The PREPARE statement is used to query-by-example because the SELECT statement, specifically the WHERE clause, is different for each execution of a query.

The PREPARE statement is used to achieve such a translation. In the example above, the PREPARE looks at select_stmt (at run-time) and attaches an identifier to it (in the example above, that statement ideQtifier^s-caited ex_stmt1).

The PREPARE looks at the select_stmt variable and attempts to translate it into a SELECT statement that the engine can understand. If there is a typo in the SELECT statement, a missing space, or some other inaccuracy, the PREPARE statement gives you a run-time fatal error. If all goes well, the statement identifier is placed in memory and can be used as if it were a SELECT statement.

PREPARE Used for Other SQL statements The ing. PREPARE Was required for the query-by-example because the SELECT statement kept changThe PR h they EPARE statement can be used on other SQL statements to increase the speed at whicexecute.

WHAT DONT YOU KNOW

INSERT INTO customer VALUES ( ? , ? , ? , ? , ? , ? , ? , ? , ? )

DELETE FROM customer WHERE customer.customer__num=?

UPDATE customer SET (fname, lname, company, addressl,

address2, city, state, zipcode, phone) = (?,?,?,?,?,?,?,?,?) WHERE

customer.customer_num = ?

WHAT DONT YOU KNOW?

About an SQL statement? In the above all of the unknown values have been replaced with question marks. Let's look at each of these SQL statements individually.

PREPARE statement

Page 220: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

219

INSERT STATEMENT

The Insert statement does not use a column list; it is therefore, assumed that the values list contain one value for every column in the customer table. There are 10 questions marks representing their unknown values are shown in the example.

DELETE STATEMENT

The only thing not known about the DELETE statement is which row should be deleted The primary key is what gives you this information; therefore it is the primary key-that is unknown. The primary key for the customer table is customer_num, so one question mark is needed to represent the unknown value.

UPDATE STATEMENT

The UPDATE statement is kind of a combination of INSERT and DELETE as far as what is unknown, you do not known what the new values are going to be, and you do not know which row is going to change.

NOW YOU KNOW

Now you know what you do not know, and what is important when it comes to the PREPARE statement. Unlike a query, you, not the end user, supply the information that is unknown will eventually.

FILLING IN THE QUESTION MARKS

Suppose the user queries for a set of rows. As the user goes through the rows, the values in the program variables change. If the user then chooses to delete a row, the value that was missing for the DELETE statement. Is now known. It is contained in program variables. All you have to do is switch the . question marks for the appropriate program variable(s).

PREPARE THE STATEMENTS

Once the SQL statements have been placed into a large character variable, you can prepare them, the PREPARE, statement-will parse the SQL statement and place the identifier in memory to be used where needed.

PLACEMENT OF THE PREPARE CRITICAL

The placement of the PREPARE statement is critical to optimizing the execution of these SQL statements, if the PREPARE statement is executed every time the user chooses the delete option, then you have not gained any speed; in fact, you have lost some.

Every module that contains an SQL statement should have a function at the top that prepares all of the SQL statements needed for that module. This is due to the fact that prepared statements are modular scope.

USING THE PREPARE STATEMENT

Now you haveivtiUnch of SQL statements that have prepared. How do you use them?

Page 221: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

220

THE EXECUTE STATEMENT

The execute statement looks in memory for the specified identifier and expects one value to be supplied for every -question mark that was that each question mark represents.

WHAT CAN BE PREPARED?

The statements you will want to PREPARE most often are

=> SELECT => INSERT => UPDATE => DELETE

(Mainly all data manipulation language (DML) statements. But any SQL statement

can be prepared You cannot PREPARE the following statements:

=> CLOSE => DECLARE

=> FETCH => WHENEVER => DEFER INTERRUPT => PREPARE => ANY INFORMIX-4GL STATEMENT

This includes the cursor statements, window statements and menu statements.

There are two potential problems with a scroll cursor:

The size of the temporary table can grow quite large. The data can become stale.

Large Temporary Tables:

All the rows that satisfy to SELECT will be written to a temporary table. This can cause temporary tables to grow quite large an may leave Temporary problem in these temporary tables are created. .

for example, the customer table takes 134 bytes to store a row. If there were 20,000 rows in the customer table and you SELECT all rows, if would take temporary tables of over 2 megabytes to store the retrieved rows. Stale Data : There is a second problem with a SCROLL cursor. Once the

rows have been read into a temporary table, all subsequent fetches come from this temporary table. This means that if another user updates of deletes a row from the customer table, Those changes would not be reflected in the temporary table until the SCROLL cursor is re-opened.

Once you have an understanding of cursors, the solution can be stated very simply.

Page 222: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

221

1. To reduce the size of the temporary table that is created, either selects fewer rows or fewer columns. A scroll cursor is commonly associated with the CONSTRUCT statement. Since the user implements the WHERE clause with CONSTRUCT, you have no control over how many rows are retrieved. That leaves the other solution, selecting fewer columns.

2. There is only one way to solve the stale data problem. Every time a FETCH statement is executed, the row should come from the actual table and not the temporary table.

To implement the solution, you use two cursors, the first cursor, shown above, will be a scroll cursor, but it will only select the primary key from the customer table rather than all of the columns.

Each time a FETCH statement is executed against this cursor, only the primary key value is loaded into a program variable. This value will then be used in the database, based on the primary key supplied by the first cursor.

The second cursor will select the entire row. Each time a FETCH4s.executed against the first cursor, the second cursor is opened and FETCH statement is executed against it. What is an Array? _

An array is defined as a repetition of a collection of fields. The decision of which fields to include in an array is up to the programmer. Each repetition is referred to as an element. Each element contains one occurrence of all the fields.

Steps necessary for a single row of data entry

=> A form must be created, opened and displayed. =z> A program record is defined. =>

The INPUT statement is used to allow data entry. => Control blocks are used for data

validation.

=> The INSERT statement is used to place the values contained in the program variables into a database table.

=> The SQLCA.SQLCODE variable is used to test for success.

The steps needed for the multiple rows of data entry.

=> A form must be created, opened and displayed. This form is similar to the one used for- single data entry except the fields are prepared several times.

=> A screen array must be defined. This is a new step that was not needed for single row data entry.

=> Program variables must be defined. This will be a program array. It uses the DEFINE statement with a different syntax.

=> An INPUT ARRAY will be used to allow data entry. This is similar —fort he INPUT statement. It allows some additional features needed for arrays".

Page 223: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

222

=> The INSERT statement will be is place the values contained in the program variables into a database table Since there a possibility of many rows being input during the INPUT statement, the INSERT statement will be placed inside a loop.

=> The SQLSQLCODE variable can be used to check the success of the INSERT.

A comparison of the steps needed for single row data entry and multiple row data entry reveals that one additional steps is needed for multiple rows; the creation of a screen array. Also, several modifications to the syntax of existing statements will need to be made.

DATABASE stores SCREEN SIZE 24 BY 80

Code manufacture

[aO] [fOOO] ' [aO] [£000] [aO] • [fOOO] [aO] [fOOO] [aO] [fOOO] } END TABLES manufact ATTRIBUTES ' ao = manufact.manu_code, UPSHIFT; fOOO = manufact.manu_name;

INSTRUCTIONS SCREEN RECORD sa_manufact[5].

(manu_code, manu_name) , E N D

SCREEN RECORDS : You can use the SEREEN RECORD statement in the INSTRUCTIONS section to reference groups of fields as a unit, or to define an array. The SCREEN RECORD is most commonly associated with arrays. This is the only way to have a form recognize the repetition of a collection of fields.

In the example above, a screen array is defined to contain five elements with two fields in each element. This gives you a total of ten fields .the individual fields can be referenced in the following manner;

SCREEN_ARRAY [element number].field_name

Page 224: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

223

INPUT ARRAY STATEMENT

The INPUT ARRAY statement is used to allow data entry into a program array. Before using the INPUT ARRAY statement, you must have created a form that has a SCREEN ARRAY defined in the INSTRUCTIONS section, and defined a program array. Same features of INPUT and INPUT ARRAY statement Turn control of the program over to the user.

Display any default values, which have been specified by the DEFAULT attribute of a form specification file. Let the user enter information into the fields of the form. Transfer the information automatically into the program variables. Wait for a signal from the user that they have finished their data entry.

Some additional features that are not needed with a single row INPUT. The INPUT statement initializes the program variables • to null. The INPUT ARRAY statement only initializes the program variables to null as they are used. This is a subtle, but very important, difference. This having some additional clauses BEFOER ROW. The INPUT ARRAY statement allows you to use the arrow keys to move up and down in the array.

DEFINING VARIABLES AS EXPLICIT RECORDS

Syntax : define record name ARRAY [num-elements] of record • variable-name data-type, variable-name data-type END RECORD

Ex. DEFINE c_name ARRAY[5] OF RECORD Fname CHAR (10), Lname CHAR (15) End Record

The Define Keyword is followed by the name of record. The record name will be used to refer to the group of variables contained within. The record name is followed by the ARRAY keyword with the number of elements contained in the ARRAY listed in brackets

The keyword OF IS USED ONLY WHEN defining array records. Following the keywords RECORD is the list of variables to be included in the record and the data type for each variable. The END RECORD keyword is required when defining explicit ARRAY records.

DEFINING VARIABLES AS IMPLICIT RECORDS

Syntax : . . . - . define record-name ARRAY [num-elements] .

o f r ecord l i ke t ab le . SCREEN ARRAY

You can think of the screen array as porthole that sits on the top of the programme ARRAY. In the example above the user has capability to enter upto ten rows (elements), but they can only see 5 continuous rows at any given time. By using the arrow key the user can move up and down in the programme array.

Page 225: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

224

This is how the screen array and programme array works together.

INSTRUCTIONS SCREEN RECORD gajmanufact [5]

(manu_name manu_code)

SCREEN ARRAY ' PROGRAM ARRAY

[ANZ] [ANZA ] [ANZ] [ANZA ] [HSK] [HUSKY ] [HSK] [HUSKY. ] [HRO] [HERO ] . [HRO] [HERO ] [NRG] [NERGE ] [NRG] [NERGE ] [SMT]■ [SMITYH ] • [SMT] [SMITYH ]

[SPD] [SPANDO ] [SPD] [SPANDO ] [TRC] [TRAVCO ] [TRC] [TRAVCO ' ] [ ■ ] [ ] [ ] [ ] [ ] t ' ] [ 1 [ 1 [ ] [ ] [ ] [ 1

THE INPUT ARRAY STATEMENT

Syntax : INPUT ARRAY program-array

FROM screen-array.* Example : INPUT ARRAY ga_manufact # cannot have the * FROM sa_manufact.* # must

have the *

The INPUT ARRAY statement allows you to enter information into a screen array and automatically transfers it to the program array. The INPUTARRAY:

=> Turns control of the program over to the user.

=> Displays any default values, which have been specified by the DEFAULT attribute of a form

specification file. .

=> Allows the user to enter Information into the program array variables. => Waits for a signal from the user that they have finished their data entry.

Must allow entry in all fields.

Page 226: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

225

The function keys F1 through F4 are used to manipulate the array.

=> The F1 key will insert a blank element into the array. This does not add an element to the original

dimension; it simply moves all the elements down one and opens up blank elements.

=> The F2 key is used to delete an element.

=> The F3 key is used to scroll down one page. The number of elements in the screen array is

considered a page.

=> The F4 key is used to scroll up one page

The OPTIONS statement:

Syntax :

OPTIONS INSERT KEY key-list, DELETE KEY key-list,. INXT KEY key-list, PREVIOUS KEY key-list

Example : OPTIONS INSERT KEY CONTROL-O, DELETE KEY CONTROL-E, INXT KEY CONTROL-S, PREVIOUS KEY CONTROL-P

This-all are associated with the ARRAY ELEMENTS

Page 227: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

226

arr_count() FUNCTION

This is a library function included with the INFORMIX-4GL product. It is arr_count() that knows how many elements are filled in the program array. This can be used in for loop. The for loop will execute arr_count() times.

Syntax for INPUT ARRAY INPUT ARRAY program-array

[WITHOUT DEFAULTS,] FROM screen-array.* [HELP help-number] [ATTRIBUTE (attr ibute l ist)] [BEFORE

{INPUT | ROW | INSERT | DELETE } (BEFORE FIELD (field l i s t ) } ] [AFTER

{INPUT | ROW | INSERT | DELETE } (AFTER FIELD (field l i s t ) } ]

DISPLAY ARRAY STATEMENT

Before data can be displayed, it must first be retrieved from the database and stored in a program array. To retrieve data from the database:

=> DECLARE A CURSOR => OPEN A CURSOR => FETCH the data into the program array => Check th5_ SOLCA SQLCODE variable => CLOSE THE CURSOR

Before using the DISPLAY ARRAY statement, you must have P

: Pcreated a form that has a screen array defined in the instruction

• section of a form. You mustalso define a program array.

Theand multiple rows are:The data is fetched into an array. rather than a record variable? The FETCH is done a WHILE LOOP. Since the data is stored in an array, you need to increment a variable that determines which element of the array is populated.

Page 228: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

228

The FOREACH statement

This is a shorthand equivalent to the OPEN-FETCH-CLOSE statement in a loop. The FOREACH statement:

=> open a cursor => execute a fetch for each row of data that is found

=> when the last row is retrieved, the FOREACH loop is exited => close the cursor.

calling set_count (expr)

LET stte_cnt =1 . FOREACH loadstate INTO ga_state[state_cnt].*

LET state_cnt = state_cnt +1 END FOREACH LET state_cnt = state_cnt - 1 CALL set_count(state_cnt) DISPLAY ARRAY ga_state TO sa_state.*

Checking Array Bounds

DEFINE ga_state ARRAY[50] OF RECORD LIKE stte.*

LET stte_cnt = 1 P

#P

FOREACH loadstate INTO ga_state[state_cnt].* .LET state_cnt ="state_cnt + 1 IF state_cnt > 50 THEN EXIT FOREACH END IF END FOREACH

define i smallint let i =1 declare loadstate "cursor for

select * from state order by code foreach loadstate into ga_state[i].* let i = i + 1 if i > 50 then.

exit foreach end if

end foreach

Page 229: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

229

16. OFB COMMNET

Introduction OFB COMNET is short form for Ordnance Factory Board COMMunication NETwork. It is basically a communication network connecting 40 Ordnance Factories, 3 OFB Head Qtrs, NADP Nagpur, OF CELL, New Delhi and 8 Nos of Ordnance Factories Institute of Learning. OFB COMNET is a MPLS VPN (Multi Protocol Label Switching - Virtual Private Network). VPN is constructed by using Public wires to connect nodes, setup solely for the users of a single Company i.e. Ordnance Factories Organisation. These Networks use encryption and other security Mechanisms to ensure that only authorized users can access the network and the data can not be intercepted. MPLS VPN back bone connectivity is provided by BSNL and the commissioning and installing of OFB COMNET is done by M/s. HCL COMNET Ltd. Applications of OFB COMNET

a. OFB Web mail b. ftp(File Transfer Protocol) Server c. IP Phone

OFB Webmail It is same as e-mail in Internet. OFB Webmail is used to send/receive e-mails through OFB COMMNET. Each Factory/Unit/Establishment and all IOFS officers are given an unique Webmail ID and password. The default password is dba1906s (in lower case letters) which can be changed if needed. Opening OFB Webmail

- Open the Internet Explorer - Type the Address as HTUhttp://mail.ofb.netUTH or HTUhttp://172.20.100.20/webmail UTH - It display the OFB MAIL login screen - Type your User name and Password User Name : sysadmin.ofilmk (For OFIL Medak) Password : dba1906s - It displays the Inbox of OFILMK - We can now view the Mails, Compose the Mails just like Internet e-Mails. - We can change the Password by using the Options available on the Webmail Page.

WEB Server It is OFB Web server that contains data pages about Ordnance Factories Organisation. To Open the OFB Web Server.

- Open the Internet Explorer - Type the address as HTUhttp://ofb.netUTH or HTUhttp://172.20.100.22 UTH at the Internet

Explorer Address Bar - Then the OFB Website will be displayed

Page 230: COMPUTER APPLICATIONS & INFORMIXofilmk.gov.in/att/JWM Course Materials/V. Computer Applications... · 1. BASICS & WINDOWS O.S 1. COMPUTER FUNDAMENTALS Introduction Computer is an

OFILMK

230

- You can view the Required Information about OFB Organisations, Ordnance Factories and its products etc.

IP Phone IP Phone is just like a WAN Phone. By using OFB COMNET we can also make Telephones by using IP Phone. Head of Department, System Administrator and some IOFS officers are given IP Phones. IP Phone number is 4 digits Number XX00 IP Phone number of the System Administrator of the Unit XX01 IP Phone number of the Head of the Department 8000 is the IP Phone Number of OFILMK System Administrator (Shri U, Srinivasa Rao, Director is the system Administrator of OFIL MK) 8001 is the IP Phone Number of Principal Director/OFILMK (Shri S. Ravi, Principal Director/OFILMK)