1 / 18

CL Programming with Database Files

CL Programming with Database Files. Updated Summer 2007. Agenda . Review of Database Objects CL Programming CL Programming exercise. Physical Files. Store Data Have record formats Can have keys (access paths) Created using DDS Code or SQL. Object types.

marika
Download Presentation

CL Programming with Database Files

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CL Programming with Database Files Updated Summer 2007

  2. Agenda • Review of Database Objects • CL Programming • CL Programming exercise

  3. Physical Files • Store Data • Have record formats • Can have keys (access paths) • Created using DDS Code or SQL

  4. Object types Opt Member Type Text AINTDEMO PF demo for external single field APTRNSDF DSPF APTRNSDF2 DSPF APVENDOR PF in class developed ARCUST PF ASSIGNMENT 2 and in class 3/4 ARCUSTLF2 LF ASSIGNMENT 2 and in class 3/4 ARCUSTX PF ASSIGNMENT 2 and in class 3/4 Opt Object Type Attribute Text PATIENT *FILE PF-DTA PRFOUT *FILE PF-DTA Output file for DSPUSRPRF QCBL *FILE PF-SRC program sources QCBLSRC *FILE PF-SRC program sources QCL *FILE PF-SRC cl program sources QCLPSRC *FILE PF-SRC Cl Sources TYPE And SUBTYPE

  5. Logical Files • Do not store data • Stores key fields and record addresses • Another view of the data • Created using DDS Code or SQL

  6. Files defined Physical file Logical file A* Physical file ARCUST ACCOUNTS RECEIVABLE Master File A UNIQUE A R ARCUSTR A CUSTNO 5S 0 TEXT('CUSTOMER NUMBER') A ALIAS(AR_CUST_NUMBER) A NAME 30A TEXT('CUSTOMER NAME') A ALIAS(AR_CUST_NAME) A SALESMAN 2S 0 TEXT('SALESMAN') A ALIAS(AR_SLSM_NUMBER) A*Logical file ARCUSTLF based on Physical file ARCUST ACCOUNTS A* RECEIVABLE Master File A* A UNIQUE A R ARCUSTRL PFILE(ARCUST) A CUSTNO A NAME A SALESMAN A STATUS K CUSTNO S NAME COMP(EQ 'BERNS') O NAME COMP(EQ 'SWISS')

  7. Steps to create a DDS OBJECT? On the green screen Create a source physical file (once) CRTSRCPF F12 (work with) Add a member F6 in WRKOBJPDM level Code / edit the member WRKMBRPDM Compile to create CRTPF / CRTLF / CRTDSPF In a GUI Navigate to the desired level and add the required object by right clicking and selecting

  8. DDS/SQL Programming Review Create a file to hold customer information (Customer number , name, account balance and type). Create a logical view by Customer Name

  9. CL Programming with Database Objects

  10. Great extra reading See IBC233 home page!!

  11. CL Programming Restrictions • Only five *FILE per program • Display file or Database File • Can’t update Database Files • Can’t create reports

  12. File Commands • DCLF - Declares a Filee.g. DCLF FILE(STUDENTS) • RCVF - Reads a record from a screen or database file • SNDRCVF is used only with display files, NOT database files! • SNDF – sends a record to a screen The Send File (SNDF) command is used by a CL procedure to send a record to a display device that is being used by an interactive user. The device can be any display station, including the console.The command sends the data from the program's CL variables to the display's device file in the specified record format. These variables were automatically declared in the program (one for each field in the record format) when the CL source program was compiled and a Declare File (DCLF) command was processed as part of the source

  13. Example Write a CL program which reads the customer file, calculates the account balance and displays it to the user.

  14. Pseudo Code Initialize variables Receive information Do while not end of file Update account balance total Receive information End of file: format the message to display the total account balance

  15. Monitoring for messages • When something unusual happens, the system sends a message back to the program. • It is up to the program to ‘trap’ the message if necessary and take the appropriate action.e.g. an end-of-file condition (msg CPF0864)

  16. Monitor Message Example RCVF MONMSG MSGID(CPF0864) + EXEC(GOTO CMDLBL(ENDIT))

  17. Programming tasks • Create a display file that uses all of the fields from the customer file. All of the fields should be output only. The text, ‘Customer owes money’ should be conditioned based on an indicator. • Write a program that displays each record in the customer file using the above display file. The text, ‘Customer owes money’ should be displayed if the account balance field is greater than zero.

  18. Don’t forget Lab 7 due on July 6 before lab starts Assignment 2 due on Friday July 13 Do NOT forget to modify your “BYEBYE” program to authorize me to ALL your objects, libraries and all the objects within the a libraries!!

More Related