170 likes | 291 Views
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
E N D
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 • Stores key fields and record addresses • Another view of the data • Created using DDS Code or SQL
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
Great extra reading See IBC233 home page!!
CL Programming Restrictions • Only five *FILE per program • Display file or Database File • Can’t update Database Files • Can’t create reports
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!
Example Write a CL program which reads the customer file, calculates the account balance and displays it to the user.
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
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)
Monitor Message Example RCVF MONMSG MSGID(CPF0864) + EXEC(GOTO CMDLBL(ENDIT))
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.