If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Very beginner needs help with Cobol & SQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-02-04, 21:24
jbrott jbrott is offline
Registered User
 
Join Date: Nov 2004
Location: Fremont, NE
Posts: 3
Unhappy Very beginner needs help with Cobol & SQL


I found this site from a search on Cobol and SQL. Not sure if anyone here can help me. I do hope so.
I need some detailed help, if your up to the challenge please respond. I don't think this is very difficult but I am new to this.
I have an EMPLOYEE database with and EMPLOYEE table containing the following fields:
(I am attempting to use NET EXPRESS to create a .cpy file)
I am looking at some help (in all aspects of this program)
Code a program that retrieves records from and Employee table in the Employee database. Records are to be retrieved by either EMPID or Last Name.

Since there is the possiblity of multiple records containing the same last name, I would like to use a cursor.
If there are multiple records for a last name, display all the names (last, first, and middle initial) on the screen in numbered rows and let the user select the employee by entering the row number.
(Do not do this if only one record is retrieved)
Display all the information for the selected employee on the output screen.
Design an output screen that is plane jane and easy to read.
To test the program create an EMPLOYEE database with an EMPLOYEE table containing the following fields:
EMPID TEXT(6)
FNAME TEXT(12)
MI TEXT(1)
LNAME TEXT(15)
BDATE TEXT(6)
HIREDATE TEXT(6)
DEPARTMENT TEXT(3)
SALARY DESIMAL (2 DECIMALS)

The host variable for the SALARY field should have a PIC of
S9(5)v99 COMP-3.

I am not going to lie, this is for a class that I am in. I ended up having to travel for work and missed two class periods and our book does not provide much of any assistance.
(The name of the book is DB2 for the COBOL Programmer)
Reply With Quote
  #2 (permalink)  
Old 11-02-04, 22:38
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
About 10,000 questions pop to my mind.

The first observation I can offer is that your instructor or one of your TAs can do a FAR better job than you're likely to find on the internet. There are so many questions that are implementation specific (such as which COBOL compiler, what runtime environment, what development tools do you have, which version of DB2 are you using... the list goes on and on) that it would be really difficult for us to give you the kind of concrete help that you need at this stage of the learning process.

With that much being said, I'd be happy to answer any questions that I can, although most of the questions you're likely to ask will provoke at least six from me before I can answer. I'm quite familiar with two different COBOL compilers, and about a dozen different SQL implementations (including 2 htat are running DB2).

-PatP
Reply With Quote
  #3 (permalink)  
Old 11-03-04, 13:19
jbrott jbrott is offline
Registered User
 
Join Date: Nov 2004
Location: Fremont, NE
Posts: 3
Additional Information

I understand, I tell you I am at such a loss that I will accept any help you can provide.
I am using Microfocus.Net 4.0.
Here is the one example of what I am looking at.
Now this program returns data for just one Custno.
I can follow the code but say I was to change the query to look up the LName
and there was 4 Smiths.
The program is supposed to then give you the option to select a number 1, 2, 3 or 4 and then display all the information for that LName.
Hope this helped you see a little more of what I am looking at.

On the next thread I will show the example from what I am talking about.
Over 10000 chars

Thanks
Reply With Quote
  #4 (permalink)  
Old 11-03-04, 13:31
jbrott jbrott is offline
Registered User
 
Join Date: Nov 2004
Location: Fremont, NE
Posts: 3
Code ID thru 140

Identification Division. 01
* 01
Program-id. Salesinq. 01
* 01
Environment Division. 01
* 01
Input-output Section. 01
* 01
File-control. 01
* 01
Data Division. 01
* 01
File Section. 01
* 01
Working-storage Section. 01
* 01
01 Switches. 01
* 01
05 End-of-inquiries-sw Pic X Value 'n'. 01
88 End-of-inquiries Value 'y'. 01
05 Customer-found-sw Pic X Value 'y'. 01
88 Customer-found Value 'y'. 01
05 Valid-cursor-sw Pic X Value 'y'. 01
88 Valid-cursor Value 'y'. 01
05 End-of-invoices-sw Pic X Value 'n'. 01
88 End-of-invoices Value 'y'. 01
* 01
01 Invoice-total-fields Comp-3. 01
* 01
05 Invoices-count Pic S9(5) Value Zero. 01
05 Invoices-total Pic S9(7)v99 Value Zero. 01
* 01
01 Edited-total-fields. 01
* 01
05 Edited-count Pic Z(4)9. 01
05 Edited-total Pic Z(6)9.99. 01
* 01
Exec Sql 01
Include Customer 05
End-exec. 01
* 01
Exec Sql 01
Include Invoice 05
End-exec. 01
* 01
Exec Sql 01
Include Sqlca 01
End-exec. 01
* 01
Exec Sql 01
Declare Invcurs Cursor For 01
Select Invno, Invdate, Invtotal 01
From Mm01.invoice 05
Where Invcust = :custno 01
End-exec. 01
* 01
Procedure Division. 01
* 01
000-process-sales-inquiries. 01
* 01
Perform 100-process-sales-inquiry 01
Until End-of-inquiries. 01
Stop Run. 01
* 01
100-process-sales-inquiry. 01
* 01
Move 'y' To Customer-found-sw. 01
Perform 110-accept-customer-number. 01
If Not End-of-inquiries 01
Perform 120-get-customer-row 01
Perform 130-display-customer-info 01
If Customer-found 01
Perform 140-get-invoices-information 01
Perform 200-display-sales-totals. 01
* 01
110-accept-customer-number. 01
* 01
Display '------------------------------------------------'. 01
Display 'key In The Next Customer Number And Press Enter,'. 01
Display 'or Key In 999999 And Press Enter To Quit.'. 01
Accept Custno. 01
If Custno = '999999' 01
Move 'y' To End-of-inquiries-sw. 01
* 01
120-get-customer-row. 01
* 01
Exec Sql 01
Select Fname, Lname 01
Into :fname, :lname 01
From Mm01.customer 05
Where Custno = :custno 01
End-exec. 01
If Sqlcode Not = 0 01
Move 'n' To Customer-found-sw. 01
* 01
130-display-customer-info. 01
* 01
Display '------------------------------------------------'. 01
If Customer-found 01
Display ' Customer ' Custno ' -- ' Fname ' ' Lname 01
Display ' ' 01
Else 01
Display ' Customer Number ' Custno ' Not Found.'. 01
* 01
140-get-invoices-information. 01
* 01
Move 'y' To Valid-cursor-sw. 01
Perform 150-open-invoice-cursor. 01
If Valid-cursor 02
Move 'n' To End-of-invoices-sw 01
Move Zero To Invoices-count 01
Move Zero To Invoices-total 02
Perform 160-get-invoice-information 01
Until End-of-invoices 02
Perform 190-close-invoice-cursor. 01
* 01
Reply With Quote
  #5 (permalink)  
Old 11-03-04, 13:41
jbrott jbrott is offline
Registered User
 
Join Date: Nov 2004
Location: Fremont, NE
Posts: 3
Code 150 to 200

150-open-invoice-cursor. 01
* 01
Exec Sql 01
Open Invcurs 01
End-exec. 01
If Sqlcode Not = 0 01
Move 'n' To Valid-cursor-sw. 01
* 01
160-get-invoice-information. 01
* 01
Perform 170-fetch-invoice-row. 01
If Not End-of-invoices 01
Add 1 To Invoices-count 01
Add Invtotal To Invoices-total 01
Perform 180-display-invoice-info. 01
* 01
170-fetch-invoice-row. 01
* 01
Exec Sql 01
Fetch Invcurs 01
Into :invno, :invdate, :invtotal 01
End-exec. 01
If Sqlcode Not = 0 01
Move 'y' To End-of-invoices-sw 01
If Sqlcode Not = 100 01
Move 'n' To Valid-cursor-sw. 01
* 01
180-display-invoice-info. 01
* 01
Move Invtotal To Edited-total. 01
Display ' Invoice ' Invno ' ' Invdate ' ' Edited-total. 01
* 01
190-close-invoice-cursor. 01
* 01
Exec Sql 01
Close Invcurs 01
End-exec. 01
If Sqlcode Not = 0 01
Move 'n' To Valid-cursor-sw. 01
* 01
200-display-sales-totals. 01
* 01
If Valid-cursor 01
Move Invoices-total To Edited-total 01
Move Invoices-count To Edited-count 01
If Invoices-total > 0 01
Display ' ------------' 01
End-if 01
Display ' Total Billed ' Edited-total 06
Display ' Invoices Issued ' Edited-count 06
Display ' ' 01
Else 01
Display ' ' 01
Display ' *** Invoice Retrieval Error ***' 01
Display ' '. 01
* 01
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On