|
Newbie
Join Date: Dec 2004
Posts: 5
Rep Power: 0 
|
Alas, I am but a grasshopper with it comes to C++ and was wondering if you C++ gurus could help me out. I am not asking for you to write the code for me but just give some guidance, resources, hints, possible problems, etc. Here is the assignment:
Assignment:
In general, your C++ program will create an SQL script file. When the script file is executed (by using the START OUTPUT.SQL command in Oracle), this script will create a new table in the database and add data into the table. The name of the table and the names for the table's fields will be specified by the user. The data that will be added to this table will come from the CUSTOMER.TXT file.
* Your program should begin by asking the user to enter the name for a new database table.
* Your program should then ask the user to enter seven names to use for seven fields that will be created in the table.
* Next, your program should create an output text file called OUTPUT.SQL
* In the output file, your program should write the SQL command necessary to remove a table from the database. The table's name was specified by the user in step one above.
* In the output file, your program should write the command(s) necessary to create a new table. The table's name was specified by the user in step one above. The table will contain seven fields and the names of the fields were specified by the user in step two above. The first six fields will hold character data and the seventh field will hold numeric data. You will need to examine the data in the CUSTOMER.TXT file to determine the specific properties of these fields such as:
variable or fixed length character fields
size limits on the fields
integer or floating point number field
which one is the best choice for primary key
Note that each field in the CUSTOMER.TXT file is separated with a comma.
* Next, your program should begin reading data from the CUSTOMER.TXT file. For every line found in the customer file, your program should write into the output file, an SQL statement used to insert data into the newly created table.
For example, you will read the first line of data in the CUSTOMER.TXT file; this line contains seven pieces of data separated by commas. You should write, into the output file, an SQL statement which will add these seven pieces of data as a new record in the table. Your program would then read the second line in the CUSTOMER.TXT file and write an SQL statement which will add these seven pieces of data as a second new record in the table.
Note that the current file contains 10 records, but your program should not rely on that. My test file may contain any number of records, including the possibility of zero records.
Also note, if you find two commas beside each other in the input file, this indicates a NULL data value for that particular field.
* Finally, your program should write into the output file the SQL command necessary to save the changes that your script file makes to the database.
You should test the output from your program to make sure that it is a WORKING script file. You can do this by logging into Oracle and then using the START command to have Oracle load and execute your script file.
Here is what the Customer.txt files looks like:
10010,Ramas,Alfred,A,615,844-2573,0.00
10011,Dunne,Leona,K,713,894-1238,0.00
10012,Smith,Kathy,W,615,894-2285,345.86
10013,Olowski,Paul,F,615,894-2180,536.75
10014,Orlando,Myron,,615,222-1672,0.00
10015,O'Brian,Amy,B,713,442-3381,0.00
10016,Brown,James,G,615,297-1228,221.19
10017,Williams,George,,615,290-2556,768.93
10018,Farriss,Anne,G,713,382-7185,216.55
10019,Smith,Olette,K,615,297-3809,0.00
Thank you for sharing your wisdom.
|