How to Write a Simple DB2 Program
DB2 (short for Database 2) is a database management system used for a wide variety of computing platforms. This programming language is used to access tables rather than flat files. More businesses are eliminating flat files because they are difficult to add variables to, and migrating to tables that are much easier to maintain. The following will give you some basics for DB2 programming.
Instructions
-
-
1
Start by finding the information you need to extract. You have to have the client's specifications. You need to know what type of information they are looking for in order to know what table or tables you need to access in order to complete the assignment.
-
2
Contact the person in charge of the tables to get a layout. You will need this in order to know where the data is when you are ready to put together the final information for your client. You will also need this to see the formatting of the variables so you can identify them in the correct way.
-
-
3
Identify the name of the table in your program. DB2 needs to know where to go to get the data. Programming is like giving directions. You must indicate every step for the program to be able to get to it's destination.
-
4
Add any definitions. For example, if you want all data after 2002, you would put in a statement like this: DATE_ENTER > '2002-00-00' where date_enter is the variable and the date is written in yyyy-mm-dd format. You must use the variable name that is used in the table; you can't assign your own name.
-
5
Run the program. If there are any problems than you will need to correct them and run the program again until you are able to get the data that is needed for your client. There is a link in the resource section that will help you debug your program. This is a very simple DB2 program.
-
1
Tips & Warnings
Variable names must be used exactly as they appear in the table.
Remember programming is like writing directions. You must be very precise.