1 / 16

CL Programming with Database Files

CL Programming with Database Files. Updated Summer 2008. Agenda . Review of Database Objects CL Programming CL Programming exercise Test Today!. Physical Files. Store Data Have record formats Can have keys (access paths) Created using DDS Code or SQL. Logical Files. Do not store data

zaide
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 2008

  2. Agenda • Review of Database Objects • CL Programming • CL Programming exercise • Test Today!

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

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

  5. Steps to create a DDS Program?

  6. 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

  7. CL Programming with Database Objects

  8. Great extra reading See IBC233 home page!!

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

  10. 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!

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

  12. 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

  13. 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)

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

  15. 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.

  16. Have a great break week!Next Lab: Lab 7

More Related