regarding database connectivity in COBOL

HOW TO CONNECT , USE DATABASE IN THE FOLLOWING COBOL PROGRAM BELOW

Page 1 of 1

9 Replies - 1233 Views - Last Post: 19 January 2009 - 12:15 AM Rate Topic: -----

#1 sakthisridhar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 21-December 08

regarding database connectivity in COBOL

Posted 22 December 2008 - 08:38 PM

[code]

Identification division.
Program-id.hstl.
Environment division.
Input-output section.
File-control.
SELECT HFILE ASSIGN TO "HOSTEL.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT SFILE ASSIGN TO "STUDENT.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT OUTF ASSIGN TO "MAIN.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT TEMPF ASSIGN TO "TEMP.DAT"
ORGANIZATION LINE SEQUENTIAL.

Data division.
File section.
FD HFILE.
01 INHOSTELREC PIC X(80).
FD SFILE.
01 INSTUDENTREC PIC X(80).
FD TEMPF.
01 INTEMPREC PIC X(80).
FD OUTF.
01 OUTMAINREC PIC X(80).

Working-storage section.
01 INHOSTELDETAILS.
02 PIC X(5) VALUE SPACES.
02 HNAME PIC X(15).
02 PIC X(5) VALUE SPACES.
02 ROOMNO PIC 9(3).
02 PIC X(5) VALUE SPACES.
02 TOTALBED PIC 99.
02 PIC X(5) VALUE SPACES.
02 AVAILBED PIC 99.

01 INSTUDENTDETAILS.
02 PIC X(5) VALUE SPACES.
02 SNAME PIC X(15).
02 PIC X(5) VALUE SPACES.
02 REGNO PIC X(10).
02 PIC X(5) VALUE SPACES.
02 COURSE PIC X(5).
02 PIC X(5) VALUE SPACES.
02 YEAR PIC X(10).
02 PIC X(5) VALUE SPACES.
02 FPAID PIC 9(5).


01 OUTMAINDETAILS.
02 PIC X(2) VALUE SPACES.
02 SNAME-O PIC X(15).
02 PIC X(2) VALUE SPACES.
02 REGNO-O PIC X(10).
02 PIC X(2) VALUE SPACES.
02 COURSE-O PIC X(5).
02 PIC X(2) VALUE SPACES.
02 YEAR-O PIC X(10).
02 PIC X(2) VALUE SPACES.
02 HNAME-O PIC X(15).
02 PIC X(2) VALUE SPACES.
02 ROOMNO-O PIC 9(3).
02 PIC X(2) VALUE SPACES.
02 EDATE.
03 EDD PIC 99.
03 EMM PIC 99.
03 EYY PIC 99.
77 MCH PIC 9.
77 CHECK1 PIC 9.
77 FLAG1 PIC 9.
77 NHNM PIC X(15).
77 NRNO PIC 9(3).
77 TTB1 PIC 99.
77 TTB2 PIC 99.
77 CHOICE1 PIC X.
77 TSNM PIC X(15).
77 M2REP PIC X VALUE "Y".
77 M1REP PIC X VALUE "Y".
77 MAINREP PIC X VALUE "Y".
77 ANS PIC X.
77 REPORTCHOICE PIC 9.
77 HLONSCREENCH PIC X VALUE 'T'.
77 HLONSCREENLINE PIC 99 VALUE 1.
77 HLTEMP PIC 99 VALUE 1.
77 HLSCREENPAGE PIC 99 VALUE 1.
77 TRT PIC 9(2).
77 RESP PIC X.
77 THLNO PIC X(15).
77 FLAG2 PIC 9 VALUE 0.
77 TRM PIC 9(3).
77 FK PIC 9 VALUE 0.
77 RGNO PIC X(10).
77 NRMNO PIC 9(3).
77 TLNO PIC 99.
/********* VARIABLE FOR GENERAL USE *********
77 user-name pic x(20).
77 pword pic x(20).
77 countstar pic 9(3).
77 passcount pic 9(1) value 1.
77 CHOICE pic 9.
procedure division.


/****************************** Login Form **********************************

login-form.
perform until passcount >3
add 1 to passcount
display " " with blank screen
perform docpara

display "ллллллллллллллллллллллллллллллллллллл" line 9 col 20
display "л л" line 10 col 20
display "л л" line 11 col 20
display "л USER NAME : л" line 12 col 20
display "л л" line 13 col 20
display "л PASSWORD : л" line 14 col 20
display "л л" line 15 col 20
display "л л" line 16 col 20
display "ллллллллллллллллллллллллллллллллллллл" line 17 col 20
move space to user-name
move space to pword
accept user-name line 12 col 36 with empty-check
accept pword line 14 col 36 with no-echo
if user-name is equal to "NITU" and pword is equal to "NS098"
go to createpara
else if user-name is equal to "KUNJAN" and pword is equal to "KM074"
go to createpara
else if user-name is equal to "KADIR" and pword is equal to "KD085"
go to createpara
else if user-name is equal to "HABEEB" and pword is equal to "HB087"
go to createpara
else if user-name is equal to "PIYUSH" and pword is equal to "PY106"
go to createpara
else display "WRONG USER NAME OR PASSWORD" line 5 col 27 with blink
display " TRY ONCE AGAIN !!! " line 16 col 24 with blink
accept ans
end-if
if passcount>3 then
perform exit-para
end-perform.


/*********************** DESIFN FORM *****************************
CREATEPARA.
DISPLAY (1,2) "WELCOME TO OUR PROJECT" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,26) "* * ***** ***** " WITH REVERSE-VIDEO
DISPLAY (9,26) " * * ** * ** * " WITH REVERSE-VIDEO
DISPLAY (10,26)" * * ** * ** * " WITH REVERSE-VIDEO
DISPLAY (11,26)" * * * * " WITH REVERSE-VIDEO
DISPLAY (12,26)" * ***** ****** " WITH REVERSE-VIDEO
DISPLAY (4,27) " PROJECT FOR"
DISPLAY (5,25) " HOSTEL MANAGEMENT SYSTEM "
DISPLAY (6,24) "---------------------------------"
DISPLAY (22,49) "PRESS ANY KEY TO CONTINUE"
ACCEPT ANS
PERFORM MAINPG-PARA.
/***************** MAIN PAGE FORM *******************

MAINPG-PARA.
PERFORM UNTIL MAINREP = "N"
DISPLAY (4,28) "*** MAIN FORM ***" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
DISPLAY (6,23) "1. ADD HOSTEL INFORMATION "
DISPLAY (8,23) "2. NEW STUDENT ENTRY "
DISPLAY (10,23) "3. DELETE STUDENT RECORD "
DISPLAY (12,23) "4. MODIFY STUDENT RECORD "
DISPLAY (14,23) "5. REPORT GENERATION"
DISPLAY (16,23) "6.EXIT"
DISPLAY (20,23) " ENTER YOUR CHOICE := " WITH BLINK
MOVE SPACES TO MCH
ACCEPT MCH
EVALUATE MCH
WHEN 1
PERFORM M1PARA
WHEN 2
PERFORM M2PARA
WHEN 3
PERFORM M3PARA
WHEN 4
PERFORM M4PARA
WHEN 5
PERFORM MAINREPORTPARA
WHEN 6
PERFORM EXIT-PARA
END-EVALUATE
DISPLAY (22,12) "DO YOU WANT TO CONTINUE THE PROJECT...(Y/N).. = "
MOVE SPACES TO MAINREP
ACCEPT MAINREP
IF MAINREP = "N" THEN
PERFORM EXIT-PARA
END-IF
END-PERFORM.
M1PARA.
PERFORM UNTIL M1REP = "N"
PERFORM M1CHPARA

OPEN EXTEND HFILE

PERFORM M1ENTRY2PARA
CLOSE HFILE
DISPLAY (20,12) "DO YOU WANT TO ENTER MORE RECORDS...(Y/N) := "
ACCEPT M1REP
END-PERFORM.

M1CHPARA.
MOVE 1 TO CHECK1
PERFORM UNTIL CHECK1 = 0
DISPLAY (5,25) "****ADD HOSTEL RECORD FORM****" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,12) "ENTER HOSTEL NAME = "
ACCEPT NHNM
DISPLAY (10,12) "ENTER ROOM NUMBER = "
ACCEPT NRNO
MOVE 0 TO FLAG1
PERFORM M1CHECKPARA

IF FLAG1 = 0 THEN
MOVE 0 TO CHECK1
END-IF
END-PERFORM.

M1CHECKPARA.
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (NHNM = HNAME) AND (NRNO = ROOMNO) THEN
DISPLAY (13,15) "THIS ROOM NO. ALREADY EXIST........" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (17,15) "PLEASE ENTER DIFFERENT CODE"
DISPLAY (20,20) "ENTER ANY KEY TO CONTINUE... "
ACCEPT ANS
MOVE 1 TO FLAG1
MOVE "F" TO CHOICE1
END-IF


END-READ
END-PERFORM
CLOSE HFILE
.
M1ENTRY2PARA.
MOVE NHNM TO HNAME
MOVE NRNO TO ROOMNO
DISPLAY (12,12) "ENTER NUMBER OF BEDS IN THE ROOM = "
ACCEPT TOTALBED
MOVE TOTALBED TO AVAILBED
DISPLAY (14,12) "NEW RECORD ENTERED... "
WRITE INHOSTELREC FROM INHOSTELDETAILS

M2PARA.
PERFORM UNTIL M2REP = "N"
MOVE 0 TO FLAG2
DISPLAY (4,25) "****ADD STUDENT RECORD FORM****" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

OPEN EXTEND SFILE
OPEN EXTEND OUTF
PERFORM M2ENTRYPARA
CLOSE SFILE
CLOSE OUTF
DISPLAY (20,12) "DO YOU WANT TO ENTER MORE RECORDS...(Y/N) := "
ACCEPT M2REP
END-PERFORM.
M2ENTRYPARA.
DISPLAY(6,12) "ENTER STUDENT NAME: "
ACCEPT SNAME
DISPLAY(8,12) "ENTER REGISTRATION NUMBER: "
ACCEPT REGNO
DISPLAY(10,12) "ENTER COURSE: "
ACCEPT COURSE
DISPLAY (12,12) "ENTER YEAR: "
ACCEPT YEAR
DISPLAY(14,12) "ENTER FEE PAID: "
ACCEPT FPAID
DISPLAY (16,12) "ENTER HOSTEL NAME STUDENT WANT: "
ACCEPT THLNO
PERFORM M2FEECHECKPARA.

M2FEECHECKPARA.
IF FPAID = 55000 THEN
MOVE 1 TO TRT.
IF FPAID = 50000 THEN
MOVE 2 TO TRT.
IF FPAID = 45000 THEN
MOVE 3 TO TRT.
IF FPAID = 40000 THEN
MOVE 4 TO TRT.
IF FPAID = 35000 THEN
MOVE 10 TO TRT.

PERFORM HOSTELAVAILPARA.
HOSTELAVAILPARA.
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
OPEN OUTPUT TEMPF
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (FLAG2 = 0) AND (THLNO = HNAME) AND (TRT = TOTALBED) THEN
IF (AVAILBED > 0) THEN
MOVE 1 TO FLAG2
MOVE ROOMNO TO TRM
COMPUTE AVAILBED = AVAILBED - 1
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
ELSE
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
END-READ
END-PERFORM
CLOSE HFILE
CLOSE TEMPF
PERFORM MAINENPARA.
MAINENPARA.
IF FLAG2 = 1 THEN
DISPLAY (14,12) "NEW RECORD ENTERED... " WITH BLANK SCREEN
PERFORM DOCPARA
WRITE INSTUDENTREC FROM INSTUDENTDETAILS
MOVE SNAME TO SNAME-O
MOVE REGNO TO REGNO-O
MOVE COURSE TO COURSE-O
MOVE YEAR TO YEAR-O
MOVE THLNO TO HNAME-O
MOVE TRM TO ROOMNO-O
ACCEPT EDATE FROM DATE
WRITE OUTMAINREC FROM OUTMAINDETAILS
DISPLAY (8,10) "STUDENT HAS GOT ROOM NO: " WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,38)TRM
DISPLAY (9,10) "IN HOSTEL "
DISPLAY (9,21) THLNO
PERFORM FILECOPYPARA
ELSE
DISPLAY (6,12) "ROOM IS NOT AVAILABLE IN THIS HOSTEL TRY FOR ANOTHER ONE " WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (20,20) "ENTER ANY KEY TO CONTINUE... "
ACCEPT ANS
.
FILECOPYPARA.
OPEN OUTPUT HFILE.
OPEN INPUT TEMPF.
MOVE 'T' TO CHOICE1
PERFORM UNTIL CHOICE1 = 'F'
READ TEMPF INTO INHOSTELDETAILS
AT END
MOVE 'F' TO CHOICE1
NOT AT END
WRITE INHOSTELREC FROM INHOSTELDETAILS
END-PERFORM.
CLOSE HFILE.
CLOSE TEMPF.
M3PARA.
DISPLAY (5,25) "***STUDENT FORM***" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

DISPLAY (7,20) "ENTER HOSTEL NAME TO BE VACANT: "
ACCEPT THLNO
DISPLAY (9,20) "ENTER ROOM NO. "
ACCEPT TRM
PERFORM RSEARCHPARA.

RSEARCHPARA.
MOVE 0 TO FLAG2
MOVE 'T' TO CHOICE1
OPEN INPUT OUTF.
OPEN OUTPUT TEMPF.
PERFORM UNTIL CHOICE1 = "F"
READ OUTF INTO OUTMAINDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (THLNO = HNAME-O) AND (TRM = ROOMNO-O) AND (FLAG2=0) THEN
DISPLAY " " WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
DISPLAY (4,5) "HOSTEL NAME -->> " HNAME-O
DISPLAY (4,40) "ENTRY DATE -->> "
DISPLAY (4,57) EYY
DISPLAY (4,59) "/"
DISPLAY (4,60) EMM
DISPLAY (4,63) "/"
DISPLAY (4,64) EDD
DISPLAY (6,5) "ROOM NO. -->> "ROOMNO-O
DISPLAY (8,15) "STUDENT NAME -->> " SNAME-O
DISPLAY (10,15) "REG. NO. -->> " REGNO-O
DISPLAY (12,15) "COURSE -->> "COURSE-O
DISPLAY (14,15) "YEAR -->> "YEAR-O
DISPLAY (17,10) "DELETE THIS RECORD? (Y/N)"
ACCEPT RESP
IF RESP = 'Y' THEN
MOVE 1 TO FK
MOVE 1 TO FLAG2
MOVE SNAME-O TO TSNM
DISPLAY (19,10) "RECORD DELETED......"
ELSE
WRITE INTEMPREC FROM OUTMAINDETAILS
END-IF
ELSE
WRITE INTEMPREC FROM OUTMAINDETAILS

END-IF
END-READ
END-PERFORM
CLOSE OUTF
CLOSE TEMPF
IF FLAG2 = 0 THEN
DISPLAY (15,15) "USER DOES NOT WANT TO DELETE THIS RECORD OR " WITH BLANK SCREEN
DISPLAY (16,15) "ERROR IN THE GIVEN DATA"
PERFORM DOCPARA
ELSE
PERFORM MODOFILEPARA
END-IF.
MODOFILEPARA.
OPEN OUTPUT OUTF
OPEN INPUT TEMPF
MOVE 'T' TO CHOICE1
PERFORM UNTIL CHOICE1 = 'F'
READ TEMPF INTO OUTMAINDETAILS
AT END
MOVE 'F' TO CHOICE1
NOT AT END
WRITE OUTMAINREC FROM OUTMAINDETAILS
END-PERFORM
CLOSE OUTF
CLOSE TEMPF
PERFORM MODSFILEPARA.



MODSFILEPARA.
IF FLAG2 = 1 THEN
MOVE 'T' TO CHOICE1
OPEN INPUT SFILE
OPEN OUTPUT TEMPF
PERFORM UNTIL CHOICE1 = "F"
READ SFILE INTO INSTUDENTDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (SNAME IS NOT EQUAL TO TSNM ) THEN
WRITE INTEMPREC FROM INSTUDENTDETAILS
END-IF
END-READ
END-PERFORM
CLOSE SFILE
CLOSE TEMPF
END-IF
PERFORM FILESTUCOPYPARA.
FILESTUCOPYPARA.
OPEN OUTPUT SFILE
OPEN INPUT TEMPF
MOVE 'T' TO CHOICE1
PERFORM UNTIL CHOICE1 = 'F'
READ TEMPF INTO INSTUDENTDETAILS
AT END
MOVE 'F' TO CHOICE1
NOT AT END
WRITE INSTUDENTREC FROM INSTUDENTDETAILS
END-PERFORM
CLOSE SFILE
CLOSE TEMPF
PERFORM MODHFILEPARA.

MODHFILEPARA.
IF FLAG2 = 1 THEN
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
OPEN OUTPUT TEMPF
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (FK = 1) AND ( TRM = ROOMNO) AND (THLNO = HNAME) THEN
COMPUTE AVAILBED = AVAILBED + 1
WRITE INTEMPREC FROM INHOSTELDETAILS
MOVE 0 TO FK
ELSE
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
END-READ
END-PERFORM
CLOSE HFILE
CLOSE TEMPF
END-IF
PERFORM FILECOPYPARA.

M4PARA.
DISPLAY (4,25) "*********CHANGE RECORD FORM*********" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

DISPLAY (6,28) "1.CHANGE THE HOSTEL:"
DISPLAY (8,28) "2.CHANGE THE ROOM:"
DISPLAY (10,28) "3.RETURN TO MAIN MENU:"
DISPLAY (14,28) "ENTER YOUR CHOICE:"
ACCEPT FK
EVALUATE FK
WHEN 1
PERFORM CHPARA
WHEN 2
PERFORM CRPARA
WHEN 3
PERFORM MAINPG-PARA
WHEN OTHER
DISPLAY (16,25) "WRONG CHOICE.........."
DISPLAY (17,25) "PRESS ANY KEY TO CONTINUE......"
ACCEPT ANS
GO TO M4PARA
END-EVALUATE.
CHPARA.
DISPLAY " " WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (6,12) "ENTER STUDENT REG. NO.:"
ACCEPT RGNO
PERFORM DISP1STUPARA.
DISP1STUPARA.
MOVE 0 TO FLAG2
MOVE 'T' TO CHOICE1
OPEN INPUT OUTF
PERFORM UNTIL CHOICE1 = "F"
READ OUTF INTO OUTMAINDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (RGNO = REGNO-O) THEN
DISPLAY " " WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

DISPLAY (4,5) "HOSTEL NAME -->> " HNAME-O
DISPLAY (4,40) ", ROOM NO. -->> "ROOMNO-O
DISPLAY (6,5) "STUDENT NAME -->> " SNAME-O
DISPLAY (6,40) "COURSE -->> "COURSE-O
DISPLAY (8,5) "YEAR -->> "YEAR-O
DISPLAY (10,10) "WANT TO CHANGE THE HOSTEL.? (Y/N)"
ACCEPT RESP
IF RESP = 'Y' THEN
MOVE ROOMNO-O TO TRM
MOVE HNAME-O TO THLNO
DISPLAY (12,12) "ENTER NEW HOSTEL STUDENT WANT:"
ACCEPT NHNM
DISPLAY (14,12) "ENTER NEW ROOM STUDENT WANT:"
ACCEPT NRMNO
MOVE 1 TO FLAG2
END-IF
END-READ
END-PERFORM
CLOSE OUTF
IF FLAG2 = 0 THEN
DISPLAY (12,5) "USER DOES NOT WANT TO CHANGE THE RECORD OR THERE IS SOME MISTAKE IN INPUT" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (14,12) "PRESS ANY KEY TO CONTINUE........"
ACCEPT ANS
GO TO M4PARA
ELSE

PERFORM RCHECK1PARA
END-IF.
RCHECK1PARA.
MOVE 'T' TO CHOICE1
MOVE 0 TO FLAG2
OPEN INPUT HFILE
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (ROOMNO = TRM) AND (HNAME = THLNO) THEN
MOVE TOTALBED TO TTB1
END-IF
IF (ROOMNO = NRMNO) AND (HNAME = NHNM) THEN
MOVE TOTALBED TO TTB2
END-IF
IF (ROOMNO = NRMNO) AND (HNAME = NHNM) AND (AVAILBED = 0) THEN
DISPLAY (13,12) "GIVEN ROOM NO. IS FULL."
ACCEPT ANS
MOVE 1 TO FLAG2

END-IF

END-READ
IF FLAG2 = 1 THEN
DISPLAY (17,12) "INVALID HOSTEL NAME OR ROOM NO."
MOVE 1 TO FLAG2
ACCEPT ANS
END-IF
 &n

Is This A Good Question/Topic? 0
  • +

Replies To: regarding database connectivity in COBOL

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: regarding database connectivity in COBOL

Posted 22 December 2008 - 09:56 PM

what platform, database?
Was This Post Helpful? 0
  • +
  • -

#3 sakthisridhar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 21-December 08

Re: regarding database connectivity in COBOL

Posted 23 December 2008 - 08:29 AM

View Postn8wxs, on 22 Dec, 2008 - 08:56 PM, said:

what platform, database?

GOOD EVENING SIR,

I have seen your mail just now.

you asked me what platform am i using?

I use WINDOWS-XP platform.

what database i am using?

I am having at present in my system is ORACLE 8, mssql server2000


can i use this database itself is it sufficient for the previous program which i have posted

if possible please tell step by step to how to connect, use database for the previous program.

please send the a correct program with output for database connectivity in cobol sir.

presently i have cobol 85 compiler and i use to compile and run like this

to compile i give the following command:

e:try> cobol3 p1.cob

to run i give the following command:

e:try> crun3 p1



thank you sir

Was This Post Helpful? 0
  • +
  • -

#4 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: regarding database connectivity in COBOL

Posted 23 December 2008 - 11:00 PM

[rules][/rules]
Was This Post Helpful? 0
  • +
  • -

#5 sakthisridhar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 21-December 08

Re: regarding database connectivity in COBOL

Posted 23 December 2008 - 11:39 PM

View Postn8wxs, on 23 Dec, 2008 - 10:00 PM, said:

[rules][/rules]




for the below cobol program please tell how to use database connectivity in cobol.

presently i have windows-xp platform and i have mssql server 2000 and oracle 8 database

please tell for the following how to use database connectivity for the following cobol program.

please tell step by step process sir.



[code]
Identification division.
Program-id.hstl.
Environment division.
Input-output section.
File-control.
SELECT HFILE ASSIGN TO "HOSTEL.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT SFILE ASSIGN TO "STUDENT.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT OUTF ASSIGN TO "MAIN.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT TEMPF ASSIGN TO "TEMP.DAT"
ORGANIZATION LINE SEQUENTIAL.

Data division.
File section.
FD HFILE.
01 INHOSTELREC PIC X(80).
FD SFILE.
01 INSTUDENTREC PIC X(80).
FD TEMPF.
01 INTEMPREC PIC X(80).
FD OUTF.
01 OUTMAINREC PIC X(80).

Working-storage section.
01 INHOSTELDETAILS.
02 PIC X(5) VALUE SPACES.
02 HNAME PIC X(15).
02 PIC X(5) VALUE SPACES.
02 ROOMNO PIC 9(3).
02 PIC X(5) VALUE SPACES.
02 TOTALBED PIC 99.
02 PIC X(5) VALUE SPACES.
02 AVAILBED PIC 99.

01 INSTUDENTDETAILS.
02 PIC X(5) VALUE SPACES.
02 SNAME PIC X(15).
02 PIC X(5) VALUE SPACES.
02 REGNO PIC X(10).
02 PIC X(5) VALUE SPACES.
02 COURSE PIC X(5).
02 PIC X(5) VALUE SPACES.
02 YEAR PIC X(10).
02 PIC X(5) VALUE SPACES.
02 FPAID PIC 9(5).


01 OUTMAINDETAILS.
02 PIC X(2) VALUE SPACES.
02 SNAME-O PIC X(15).
02 PIC X(2) VALUE SPACES.
02 REGNO-O PIC X(10).
02 PIC X(2) VALUE SPACES.
02 COURSE-O PIC X(5).
02 PIC X(2) VALUE SPACES.
02 YEAR-O PIC X(10).
02 PIC X(2) VALUE SPACES.
02 HNAME-O PIC X(15).
02 PIC X(2) VALUE SPACES.
02 ROOMNO-O PIC 9(3).
02 PIC X(2) VALUE SPACES.
02 EDATE.
03 EDD PIC 99.
03 EMM PIC 99.
03 EYY PIC 99.
77 MCH PIC 9.
77 CHECK1 PIC 9.
77 FLAG1 PIC 9.
77 NHNM PIC X(15).
77 NRNO PIC 9(3).
77 TTB1 PIC 99.
77 TTB2 PIC 99.
77 CHOICE1 PIC X.
77 TSNM PIC X(15).
77 M2REP PIC X VALUE "Y".
77 M1REP PIC X VALUE "Y".
77 MAINREP PIC X VALUE "Y".
77 ANS PIC X.
77 REPORTCHOICE PIC 9.
77 HLONSCREENCH PIC X VALUE 'T'.
77 HLONSCREENLINE PIC 99 VALUE 1.
77 HLTEMP PIC 99 VALUE 1.
77 HLSCREENPAGE PIC 99 VALUE 1.
77 TRT PIC 9(2).
77 RESP PIC X.
77 THLNO PIC X(15).
77 FLAG2 PIC 9 VALUE 0.
77 TRM PIC 9(3).
77 FK PIC 9 VALUE 0.
77 RGNO PIC X(10).
77 NRMNO PIC 9(3).
77 TLNO PIC 99.
/********* VARIABLE FOR GENERAL USE *********
77 user-name pic x(20).
77 pword pic x(20).
77 countstar pic 9(3).
77 passcount pic 9(1) value 1.
77 CHOICE pic 9.
procedure division.


/****************************** Login Form **********************************

login-form.
perform until passcount >3
add 1 to passcount
display " " with blank screen
perform docpara

display "ллллллллллллллллллллллллллллллллллллл" line 9 col 20
display "л л" line 10 col 20
display "л л" line 11 col 20
display "л USER NAME : л" line 12 col 20
display "л л" line 13 col 20
display "л PASSWORD : л" line 14 col 20
display "л л" line 15 col 20
display "л л" line 16 col 20
display "ллллллллллллллллллллллллллллллллллллл" line 17 col 20
move space to user-name
move space to pword
accept user-name line 12 col 36 with empty-check
accept pword line 14 col 36 with no-echo
if user-name is equal to "NITU" and pword is equal to "NS098"
go to createpara
else if user-name is equal to "KUNJAN" and pword is equal to "KM074"
go to createpara
else if user-name is equal to "KADIR" and pword is equal to "KD085"
go to createpara
else if user-name is equal to "HABEEB" and pword is equal to "HB087"
go to createpara
else if user-name is equal to "PIYUSH" and pword is equal to "PY106"
go to createpara
else display "WRONG USER NAME OR PASSWORD" line 5 col 27 with blink
display " TRY ONCE AGAIN !!! " line 16 col 24 with blink
accept ans
end-if
if passcount>3 then
perform exit-para
end-perform.


/*********************** DESIFN FORM *****************************
CREATEPARA.
DISPLAY (1,2) "WELCOME TO OUR PROJECT" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,26) "* * ***** ***** " WITH REVERSE-VIDEO
DISPLAY (9,26) " * * ** * ** * " WITH REVERSE-VIDEO
DISPLAY (10,26)" * * ** * ** * " WITH REVERSE-VIDEO
DISPLAY (11,26)" * * * * " WITH REVERSE-VIDEO
DISPLAY (12,26)" * ***** ****** " WITH REVERSE-VIDEO
DISPLAY (4,27) " PROJECT FOR"
DISPLAY (5,25) " HOSTEL MANAGEMENT SYSTEM "
DISPLAY (6,24) "---------------------------------"
DISPLAY (22,49) "PRESS ANY KEY TO CONTINUE"
ACCEPT ANS
PERFORM MAINPG-PARA.
/***************** MAIN PAGE FORM *******************

MAINPG-PARA.
PERFORM UNTIL MAINREP = "N"
DISPLAY (4,28) "*** MAIN FORM ***" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
DISPLAY (6,23) "1. ADD HOSTEL INFORMATION "
DISPLAY (8,23) "2. NEW STUDENT ENTRY "
DISPLAY (10,23) "3. DELETE STUDENT RECORD "
DISPLAY (12,23) "4. MODIFY STUDENT RECORD "
DISPLAY (14,23) "5. REPORT GENERATION"
DISPLAY (16,23) "6.EXIT"
DISPLAY (20,23) " ENTER YOUR CHOICE := " WITH BLINK
MOVE SPACES TO MCH
ACCEPT MCH
EVALUATE MCH
WHEN 1
PERFORM M1PARA
WHEN 2
PERFORM M2PARA
WHEN 3
PERFORM M3PARA
WHEN 4
PERFORM M4PARA
WHEN 5
PERFORM MAINREPORTPARA
WHEN 6
PERFORM EXIT-PARA
END-EVALUATE
DISPLAY (22,12) "DO YOU WANT TO CONTINUE THE PROJECT...(Y/N).. = "
MOVE SPACES TO MAINREP
ACCEPT MAINREP
IF MAINREP = "N" THEN
PERFORM EXIT-PARA
END-IF
END-PERFORM.
M1PARA.
PERFORM UNTIL M1REP = "N"
PERFORM M1CHPARA

OPEN EXTEND HFILE

PERFORM M1ENTRY2PARA
CLOSE HFILE
DISPLAY (20,12) "DO YOU WANT TO ENTER MORE RECORDS...(Y/N) := "
ACCEPT M1REP
END-PERFORM.

M1CHPARA.
MOVE 1 TO CHECK1
PERFORM UNTIL CHECK1 = 0
DISPLAY (5,25) "****ADD HOSTEL RECORD FORM****" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,12) "ENTER HOSTEL NAME = "
ACCEPT NHNM
DISPLAY (10,12) "ENTER ROOM NUMBER = "
ACCEPT NRNO
MOVE 0 TO FLAG1
PERFORM M1CHECKPARA

IF FLAG1 = 0 THEN
MOVE 0 TO CHECK1
END-IF
END-PERFORM.

M1CHECKPARA.
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (NHNM = HNAME) AND (NRNO = ROOMNO) THEN
DISPLAY (13,15) "THIS ROOM NO. ALREADY EXIST........" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (17,15) "PLEASE ENTER DIFFERENT CODE"
DISPLAY (20,20) "ENTER ANY KEY TO CONTINUE... "
ACCEPT ANS
MOVE 1 TO FLAG1
MOVE "F" TO CHOICE1
END-IF


END-READ
END-PERFORM
CLOSE HFILE
.
M1ENTRY2PARA.
MOVE NHNM TO HNAME
MOVE NRNO TO ROOMNO
DISPLAY (12,12) "ENTER NUMBER OF BEDS IN THE ROOM = "
ACCEPT TOTALBED
MOVE TOTALBED TO AVAILBED
DISPLAY (14,12) "NEW RECORD ENTERED... "
WRITE INHOSTELREC FROM INHOSTELDETAILS

M2PARA.
PERFORM UNTIL M2REP = "N"
MOVE 0 TO FLAG2
DISPLAY (4,25) "****ADD STUDENT RECORD FORM****" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

OPEN EXTEND SFILE
OPEN EXTEND OUTF
PERFORM M2ENTRYPARA
CLOSE SFILE
CLOSE OUTF
DISPLAY (20,12) "DO YOU WANT TO ENTER MORE RECORDS...(Y/N) := "
ACCEPT M2REP
END-PERFORM.
M2ENTRYPARA.
DISPLAY(6,12) "ENTER STUDENT NAME: "
ACCEPT SNAME
DISPLAY(8,12) "ENTER REGISTRATION NUMBER: "
ACCEPT REGNO
DISPLAY(10,12) "ENTER COURSE: "
ACCEPT COURSE
DISPLAY (12,12) "ENTER YEAR: "
ACCEPT YEAR
DISPLAY(14,12) "ENTER FEE PAID: "
ACCEPT FPAID
DISPLAY (16,12) "ENTER HOSTEL NAME STUDENT WANT: "
ACCEPT THLNO
PERFORM M2FEECHECKPARA.

M2FEECHECKPARA.
IF FPAID = 55000 THEN
MOVE 1 TO TRT.
IF FPAID = 50000 THEN
MOVE 2 TO TRT.
IF FPAID = 45000 THEN
MOVE 3 TO TRT.
IF FPAID = 40000 THEN
MOVE 4 TO TRT.
IF FPAID = 35000 THEN
MOVE 10 TO TRT.

PERFORM HOSTELAVAILPARA.
HOSTELAVAILPARA.
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
OPEN OUTPUT TEMPF
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (FLAG2 = 0) AND (THLNO = HNAME) AND (TRT = TOTALBED) THEN
IF (AVAILBED > 0) THEN
MOVE 1 TO FLAG2
MOVE ROOMNO TO TRM
COMPUTE AVAILBED = AVAILBED - 1
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
ELSE
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
END-READ
END-PERFORM
CLOSE HFILE
CLOSE TEMPF
PERFORM MAINENPARA.
MAINENPARA.
IF FLAG2 = 1 THEN
DISPLAY (14,12) "NEW RECORD ENTERED... " WITH BLANK SCREEN
PERFORM DOCPARA
WRITE INSTUDENTREC FROM INSTUDENTDETAILS
MOVE SNAME TO SNAME-O
MOVE REGNO TO REGNO-O
MOVE COURSE TO COURSE-O
MOVE YEAR TO YEAR-O
MOVE THLNO TO HNAME-O
MOVE TRM TO ROOMNO-O
ACCEPT EDATE FROM DATE
WRITE OUTMAINREC FROM OUTMAINDETAILS
DISPLAY (8,10) "STUDENT HAS GOT ROOM NO: " WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,38)TRM
DISPLAY (9,10) "IN HOSTEL "
DISPLAY (9,21) THLNO
PERFORM FILECOPYPARA
ELSE
DISPLAY (6,12) "ROOM IS NOT AVAILABLE IN THIS HOSTEL TRY FOR ANOTHER ONE " WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (20,20) "ENTER ANY KEY TO CONTINUE... "
ACCEPT ANS
.
FILECOPYPARA.
OPEN OUTPUT HFILE.
OPEN INPUT TEMPF.
MOVE 'T' TO CHOICE1
PERFORM UNTIL CHOICE1 = 'F'
READ TEMPF INTO INHOSTELDETAILS
AT END
MOVE 'F' TO CHOICE1
NOT AT END
WRITE INHOSTELREC FROM INHOSTELDETAILS
END-PERFORM.
CLOSE HFILE.
CLOSE TEMPF.
M3PARA.
DISPLAY (5,25) "***STUDENT FORM***" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

DISPLAY (7,20) "ENTER HOSTEL NAME TO BE VACANT: "
ACCEPT THLNO
DISPLAY (9,20) "ENTER ROOM NO. "
ACCEPT TRM
PERFORM RSEARCHPARA.

RSEARCHPARA.
MOVE 0 TO FLAG2
MOVE 'T' TO CHOICE1
OPEN INPUT OUTF.
OPEN OUTPUT TEMPF.
PERFORM UNTIL CHOICE1 = "F"
READ OUTF INTO OUTMAINDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (THLNO = HNAME-O) AND (TRM = ROOMNO-O) AND (FLAG2=0) THEN
DISPLAY " " WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
DISPLAY (4,5) "HOSTEL NAME -->> " HNAME-O
DISPLAY (4,40) "ENTRY DATE -->> "
DISPLAY (4,57) EYY
DISPLAY (4,59) "/"
DISPLAY (4,60) EMM
DISPLAY (4,63) "/"
DISPLAY (4,64) EDD
DISPLAY (6,5) "ROOM NO. -->> "ROOMNO-O
DISPLAY (8,15) "STUDENT NAME -->> " SNAME-O
DISPLAY (10,15) "REG. NO. -->> " REGNO-O
DISPLAY (12,15) "COURSE -->> "COURSE-O
DISPLAY (14,15) "YEAR -->> "YEAR-O
DISPLAY (17,10) "DELETE THIS RECORD? (Y/N)"
ACCEPT RESP
IF RESP = 'Y' THEN
MOVE 1 TO FK
MOVE 1 TO FLAG2
MOVE SNAME-O TO TSNM
DISPLAY (19,10) "RECORD DELETED......"
ELSE
WRITE INTEMPREC FROM OUTMAINDETAILS
END-IF
ELSE
WRITE INTEMPREC FROM OUTMAINDETAILS

END-IF
END-READ
END-PERFORM
CLOSE OUTF
CLOSE TEMPF
IF FLAG2 = 0 THEN
DISPLAY (15,15) "USER DOES NOT WANT TO DELETE THIS RECORD OR " WITH BLANK SCREEN
DISPLAY (16,15) "ERROR IN THE GIVEN DATA"
PERFORM DOCPARA
ELSE
PERFORM MODOFILEPARA
END-IF.
MODOFILEPARA.
OPEN OUTPUT OUTF
OPEN INPUT TEMPF
MOVE 'T' TO CHOICE1
PERFORM UNTIL CHOICE1 = 'F'
READ TEMPF INTO OUTMAINDETAILS
AT END
MOVE 'F' TO CHOICE1
NOT AT END
WRITE OUTMAINREC FROM OUTMAINDETAILS
END-PERFORM
CLOSE OUTF
CLOSE TEMPF
PERFORM MODSFILEPARA.



MODSFILEPARA.
IF FLAG2 = 1 THEN
MOVE 'T' TO CHOICE1
OPEN INPUT SFILE
OPEN OUTPUT TEMPF
PERFORM UNTIL CHOICE1 = "F"
READ SFILE INTO INSTUDENTDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (SNAME IS NOT EQUAL TO TSNM ) THEN
WRITE INTEMPREC FROM INSTUDENTDETAILS
END-IF
END-READ
END-PERFORM
CLOSE SFILE
CLOSE TEMPF
END-IF
PERFORM FILESTUCOPYPARA.
FILESTUCOPYPARA.
OPEN OUTPUT SFILE
OPEN INPUT TEMPF
MOVE 'T' TO CHOICE1
PERFORM UNTIL CHOICE1 = 'F'
READ TEMPF INTO INSTUDENTDETAILS
AT END
MOVE 'F' TO CHOICE1
NOT AT END
WRITE INSTUDENTREC FROM INSTUDENTDETAILS
END-PERFORM
CLOSE SFILE
CLOSE TEMPF
PERFORM MODHFILEPARA.

MODHFILEPARA.
IF FLAG2 = 1 THEN
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
OPEN OUTPUT TEMPF
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (FK = 1) AND ( TRM = ROOMNO) AND (THLNO = HNAME) THEN
COMPUTE AVAILBED = AVAILBED + 1
WRITE INTEMPREC FROM INHOSTELDETAILS
MOVE 0 TO FK
ELSE
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
END-READ
END-PERFORM
CLOSE HFILE
CLOSE TEMPF
END-IF
PERFORM FILECOPYPARA.

M4PARA.
DISPLAY (4,25) "*********CHANGE RECORD FORM*********" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

DISPLAY (6,28) "1.CHANGE THE HOSTEL:"
DISPLAY (8,28) "2.CHANGE THE ROOM:"
DISPLAY (10,28) "3.RETURN TO MAIN MENU:"
DISPLAY (14,28) "ENTER YOUR CHOICE:"
ACCEPT FK
EVALUATE FK
WHEN 1
PERFORM CHPARA
WHEN 2
PERFORM CRPARA
WHEN 3
PERFORM MAINPG-PARA
WHEN OTHER
DISPLAY (16,25) "WRONG CHOICE.........."
DISPLAY (17,25) "PRESS ANY KEY TO CONTINUE......"
ACCEPT ANS
GO TO M4PARA
END-EVALUATE.
CHPARA.
DISPLAY " " WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (6,12) "ENTER STUDENT REG. NO.:"
ACCEPT RGNO
PERFORM DISP1STUPARA.
DISP1STUPARA.
MOVE 0 TO FLAG2
MOVE 'T' TO CHOICE1
OPEN INPUT OUTF
PERFORM UNTIL CHOICE1 = "F"
READ OUTF INTO OUTMAINDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (RGNO = REGNO-O) THEN
DISPLAY " " WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

DISPLAY (4,5) "HOSTEL NAME -->> " HNAME-O
DISPLAY (4,40) ", ROOM NO. -->> "ROOMNO-O
DISPLAY (6,5) "STUDENT NAME -->> " SNAME-O
DISPLAY (6,40) "COURSE -->> "COURSE-O
DISPLAY (8,5) "YEAR -->> "YEAR-O
DISPLAY (10,10) "WANT TO CHANGE THE HOSTEL.? (Y/N)"
ACCEPT RESP
IF RESP = 'Y' THEN
MOVE ROOMNO-O TO TRM
MOVE HNAME-O TO THLNO
DISPLAY (12,12) "ENTER NEW HOSTEL STUDENT WANT:"
ACCEPT NHNM
DISPLAY (14,12) "ENTER NEW ROOM STUDENT WANT:"
ACCEPT NRMNO
MOVE 1 TO FLAG2
END-IF
END-READ
END-PERFORM
CLOSE OUTF
IF FLAG2 = 0 THEN
DISPLAY (12,5) "USER DOES NOT WANT TO CHANGE THE RECORD OR THERE IS SOME MISTAKE IN INPUT" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (14,12) "PRESS ANY KEY TO CONTINUE........"
ACCEPT ANS
GO TO M4PARA
ELSE

PERFORM RCHECK1PARA
END-IF.
RCHECK1PARA.
MOVE 'T' TO CHOICE1
MOVE 0 TO FLAG2
OPEN INPUT HFILE
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (ROOMNO = TRM) AND (HNAME = THLNO) THEN
MOVE TOTALBED TO TTB1
END-IF
IF (ROOMNO = NRMNO) AND (HNAME = NHNM) THEN
MOVE TOTALBED TO TTB2
END-IF
IF (ROOMNO = NRMNO) AND (HNAME = NHNM) AND (AVAILBED = 0) THEN
DISPLAY (13,12) "GIVEN ROOM NO. IS FULL."
ACCEPT ANS
MOVE 1 TO FLAG2

&n
Was This Post Helpful? 0
  • +
  • -

#6 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: regarding database connectivity in COBOL

Posted 24 December 2008 - 10:19 AM

Quote

please tell step by step process sir.


Post your code showing your attempt to solve this problem and we'll help you debug it. We will not provide you with a solution.
Was This Post Helpful? 0
  • +
  • -

#7 sakthisridhar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 21-December 08

Re: regarding database connectivity in COBOL

Posted 25 December 2008 - 12:06 AM

View Postn8wxs, on 24 Dec, 2008 - 09:19 AM, said:

Quote

please tell step by step process sir.


Post your code showing your attempt to solve this problem and we'll help you debug it. We will not provide you with a solution.



SIR,

I HAVE ALREDAY POSTED THE PROGRAM AND IS WORKING PERFECTLY . ANY WAY I HAVE AGAIN PASTED THE CODE YOU HAVE ASKED AND IT IS WORKING PERFECTLY WITHOUT DATABASE .


BUT I DONT KNOW HOW TO USE THE BELOW PROGRAM WITH DATABASE CONNECTIVITY . PLEASE SAY STEP BY STEP OF HOW TO CONNECT DATABASE CONNECTIVITY TO THE FOLLOWING PROGRAM.

AT PRESENT IN MY SYSTEM I HAVE ORACLE 8i , MSSQL SERVER 2000 DATABASE.

AND I AM WORKING PRESENTLY IN THE WINDOWS-XP PLATFORM.

PLEASE SAY FOR THE BELOW PROGRAM HOW TO USE DATABASE CONNECTIVITY FOR THE PASTED BELOW PROGARM WHICH I HAVE GIVEN TO YOU.

HOPE U WILL REPLY SOON WITH THE SOLUTION


THANK U SIR




[code]

Identification division.
Program-id.hstl.
Environment division.
Input-output section.
File-control.
SELECT HFILE ASSIGN TO "HOSTEL.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT SFILE ASSIGN TO "STUDENT.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT OUTF ASSIGN TO "MAIN.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT TEMPF ASSIGN TO "TEMP.DAT"
ORGANIZATION LINE SEQUENTIAL.

Data division.
File section.
FD HFILE.
01 INHOSTELREC PIC X(80).
FD SFILE.
01 INSTUDENTREC PIC X(80).
FD TEMPF.
01 INTEMPREC PIC X(80).
FD OUTF.
01 OUTMAINREC PIC X(80).

Working-storage section.
01 INHOSTELDETAILS.
02 PIC X(5) VALUE SPACES.
02 HNAME PIC X(15).
02 PIC X(5) VALUE SPACES.
02 ROOMNO PIC 9(3).
02 PIC X(5) VALUE SPACES.
02 TOTALBED PIC 99.
02 PIC X(5) VALUE SPACES.
02 AVAILBED PIC 99.

01 INSTUDENTDETAILS.
02 PIC X(5) VALUE SPACES.
02 SNAME PIC X(15).
02 PIC X(5) VALUE SPACES.
02 REGNO PIC X(10).
02 PIC X(5) VALUE SPACES.
02 COURSE PIC X(5).
02 PIC X(5) VALUE SPACES.
02 YEAR PIC X(10).
02 PIC X(5) VALUE SPACES.
02 FPAID PIC 9(5).


01 OUTMAINDETAILS.
02 PIC X(2) VALUE SPACES.
02 SNAME-O PIC X(15).
02 PIC X(2) VALUE SPACES.
02 REGNO-O PIC X(10).
02 PIC X(2) VALUE SPACES.
02 COURSE-O PIC X(5).
02 PIC X(2) VALUE SPACES.
02 YEAR-O PIC X(10).
02 PIC X(2) VALUE SPACES.
02 HNAME-O PIC X(15).
02 PIC X(2) VALUE SPACES.
02 ROOMNO-O PIC 9(3).
02 PIC X(2) VALUE SPACES.
02 EDATE.
03 EDD PIC 99.
03 EMM PIC 99.
03 EYY PIC 99.
77 MCH PIC 9.
77 CHECK1 PIC 9.
77 FLAG1 PIC 9.
77 NHNM PIC X(15).
77 NRNO PIC 9(3).
77 TTB1 PIC 99.
77 TTB2 PIC 99.
77 CHOICE1 PIC X.
77 TSNM PIC X(15).
77 M2REP PIC X VALUE "Y".
77 M1REP PIC X VALUE "Y".
77 MAINREP PIC X VALUE "Y".
77 ANS PIC X.
77 REPORTCHOICE PIC 9.
77 HLONSCREENCH PIC X VALUE 'T'.
77 HLONSCREENLINE PIC 99 VALUE 1.
77 HLTEMP PIC 99 VALUE 1.
77 HLSCREENPAGE PIC 99 VALUE 1.
77 TRT PIC 9(2).
77 RESP PIC X.
77 THLNO PIC X(15).
77 FLAG2 PIC 9 VALUE 0.
77 TRM PIC 9(3).
77 FK PIC 9 VALUE 0.
77 RGNO PIC X(10).
77 NRMNO PIC 9(3).
77 TLNO PIC 99.
/********* VARIABLE FOR GENERAL USE *********
77 user-name pic x(20).
77 pword pic x(20).
77 countstar pic 9(3).
77 passcount pic 9(1) value 1.
77 CHOICE pic 9.
procedure division.


/****************************** Login Form **********************************

login-form.
perform until passcount >3
add 1 to passcount
display " " with blank screen
perform docpara

display "ллллллллллллллллллллллллллллллллллллл" line 9 col 20
display "л л" line 10 col 20
display "л л" line 11 col 20
display "л USER NAME : л" line 12 col 20
display "л л" line 13 col 20
display "л PASSWORD : л" line 14 col 20
display "л л" line 15 col 20
display "л л" line 16 col 20
display "ллллллллллллллллллллллллллллллллллллл" line 17 col 20
move space to user-name
move space to pword
accept user-name line 12 col 36 with empty-check
accept pword line 14 col 36 with no-echo
if user-name is equal to "NITU" and pword is equal to "NS098"
go to createpara
else if user-name is equal to "KUNJAN" and pword is equal to "KM074"
go to createpara
else if user-name is equal to "KADIR" and pword is equal to "KD085"
go to createpara
else if user-name is equal to "HABEEB" and pword is equal to "HB087"
go to createpara
else if user-name is equal to "PIYUSH" and pword is equal to "PY106"
go to createpara
else display "WRONG USER NAME OR PASSWORD" line 5 col 27 with blink
display " TRY ONCE AGAIN !!! " line 16 col 24 with blink
accept ans
end-if
if passcount>3 then
perform exit-para
end-perform.


/*********************** DESIFN FORM *****************************
CREATEPARA.
DISPLAY (1,2) "WELCOME TO OUR PROJECT" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,26) "* * ***** ***** " WITH REVERSE-VIDEO
DISPLAY (9,26) " * * ** * ** * " WITH REVERSE-VIDEO
DISPLAY (10,26)" * * ** * ** * " WITH REVERSE-VIDEO
DISPLAY (11,26)" * * * * " WITH REVERSE-VIDEO
DISPLAY (12,26)" * ***** ****** " WITH REVERSE-VIDEO
DISPLAY (4,27) " PROJECT FOR"
DISPLAY (5,25) " HOSTEL MANAGEMENT SYSTEM "
DISPLAY (6,24) "---------------------------------"
DISPLAY (22,49) "PRESS ANY KEY TO CONTINUE"
ACCEPT ANS
PERFORM MAINPG-PARA.
/***************** MAIN PAGE FORM *******************

MAINPG-PARA.
PERFORM UNTIL MAINREP = "N"
DISPLAY (4,28) "*** MAIN FORM ***" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
DISPLAY (6,23) "1. ADD HOSTEL INFORMATION "
DISPLAY (8,23) "2. NEW STUDENT ENTRY "
DISPLAY (10,23) "3. DELETE STUDENT RECORD "
DISPLAY (12,23) "4. MODIFY STUDENT RECORD "
DISPLAY (14,23) "5. REPORT GENERATION"
DISPLAY (16,23) "6.EXIT"
DISPLAY (20,23) " ENTER YOUR CHOICE := " WITH BLINK
MOVE SPACES TO MCH
ACCEPT MCH
EVALUATE MCH
WHEN 1
PERFORM M1PARA
WHEN 2
PERFORM M2PARA
WHEN 3
PERFORM M3PARA
WHEN 4
PERFORM M4PARA
WHEN 5
PERFORM MAINREPORTPARA
WHEN 6
PERFORM EXIT-PARA
END-EVALUATE
DISPLAY (22,12) "DO YOU WANT TO CONTINUE THE PROJECT...(Y/N).. = "
MOVE SPACES TO MAINREP
ACCEPT MAINREP
IF MAINREP = "N" THEN
PERFORM EXIT-PARA
END-IF
END-PERFORM.
M1PARA.
PERFORM UNTIL M1REP = "N"
PERFORM M1CHPARA

OPEN EXTEND HFILE

PERFORM M1ENTRY2PARA
CLOSE HFILE
DISPLAY (20,12) "DO YOU WANT TO ENTER MORE RECORDS...(Y/N) := "
ACCEPT M1REP
END-PERFORM.

M1CHPARA.
MOVE 1 TO CHECK1
PERFORM UNTIL CHECK1 = 0
DISPLAY (5,25) "****ADD HOSTEL RECORD FORM****" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,12) "ENTER HOSTEL NAME = "
ACCEPT NHNM
DISPLAY (10,12) "ENTER ROOM NUMBER = "
ACCEPT NRNO
MOVE 0 TO FLAG1
PERFORM M1CHECKPARA

IF FLAG1 = 0 THEN
MOVE 0 TO CHECK1
END-IF
END-PERFORM.

M1CHECKPARA.
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (NHNM = HNAME) AND (NRNO = ROOMNO) THEN
DISPLAY (13,15) "THIS ROOM NO. ALREADY EXIST........" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (17,15) "PLEASE ENTER DIFFERENT CODE"
DISPLAY (20,20) "ENTER ANY KEY TO CONTINUE... "
ACCEPT ANS
MOVE 1 TO FLAG1
MOVE "F" TO CHOICE1
END-IF


END-READ
END-PERFORM
CLOSE HFILE
.
M1ENTRY2PARA.
MOVE NHNM TO HNAME
MOVE NRNO TO ROOMNO
DISPLAY (12,12) "ENTER NUMBER OF BEDS IN THE ROOM = "
ACCEPT TOTALBED
MOVE TOTALBED TO AVAILBED
DISPLAY (14,12) "NEW RECORD ENTERED... "
WRITE INHOSTELREC FROM INHOSTELDETAILS

M2PARA.
PERFORM UNTIL M2REP = "N"
MOVE 0 TO FLAG2
DISPLAY (4,25) "****ADD STUDENT RECORD FORM****" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

OPEN EXTEND SFILE
OPEN EXTEND OUTF
PERFORM M2ENTRYPARA
CLOSE SFILE
CLOSE OUTF
DISPLAY (20,12) "DO YOU WANT TO ENTER MORE RECORDS...(Y/N) := "
ACCEPT M2REP
END-PERFORM.
M2ENTRYPARA.
DISPLAY(6,12) "ENTER STUDENT NAME: "
ACCEPT SNAME
DISPLAY(8,12) "ENTER REGISTRATION NUMBER: "
ACCEPT REGNO
DISPLAY(10,12) "ENTER COURSE: "
ACCEPT COURSE
DISPLAY (12,12) "ENTER YEAR: "
ACCEPT YEAR
DISPLAY(14,12) "ENTER FEE PAID: "
ACCEPT FPAID
DISPLAY (16,12) "ENTER HOSTEL NAME STUDENT WANT: "
ACCEPT THLNO
PERFORM M2FEECHECKPARA.

M2FEECHECKPARA.
IF FPAID = 55000 THEN
MOVE 1 TO TRT.
IF FPAID = 50000 THEN
MOVE 2 TO TRT.
IF FPAID = 45000 THEN
MOVE 3 TO TRT.
IF FPAID = 40000 THEN
MOVE 4 TO TRT.
IF FPAID = 35000 THEN
MOVE 10 TO TRT.

PERFORM HOSTELAVAILPARA.
HOSTELAVAILPARA.
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
OPEN OUTPUT TEMPF
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (FLAG2 = 0) AND (THLNO = HNAME) AND (TRT = TOTALBED) THEN
IF (AVAILBED > 0) THEN
MOVE 1 TO FLAG2
MOVE ROOMNO TO TRM
COMPUTE AVAILBED = AVAILBED - 1
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
ELSE
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
END-READ
END-PERFORM
CLOSE HFILE
CLOSE TEMPF
PERFORM MAINENPARA.
MAINENPARA.
IF FLAG2 = 1 THEN
DISPLAY (14,12) "NEW RECORD ENTERED... " WITH BLANK SCREEN
PERFORM DOCPARA
WRITE INSTUDENTREC FROM INSTUDENTDETAILS
MOVE SNAME TO SNAME-O
MOVE REGNO TO REGNO-O
MOVE COURSE TO COURSE-O
MOVE YEAR TO YEAR-O
MOVE THLNO TO HNAME-O
MOVE TRM TO ROOMNO-O
ACCEPT EDATE FROM DATE
WRITE OUTMAINREC FROM OUTMAINDETAILS
DISPLAY (8,10) "STUDENT HAS GOT ROOM NO: " WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,38)TRM
DISPLAY (9,10) "IN HOSTEL "
DISPLAY (9,21) THLNO
PERFORM FILECOPYPARA
ELSE
DISPLAY (6,12) "ROOM IS NOT AVAILABLE IN THIS HOSTEL TRY FOR ANOTHER ONE " WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (20,20) "ENTER ANY KEY TO CONTINUE... "
ACCEPT ANS
.
FILECOPYPARA.
OPEN OUTPUT HFILE.
OPEN INPUT TEMPF.
MOVE 'T' TO CHOICE1
PERFORM UNTIL CHOICE1 = 'F'
READ TEMPF INTO INHOSTELDETAILS
AT END
MOVE 'F' TO CHOICE1
NOT AT END
WRITE INHOSTELREC FROM INHOSTELDETAILS
END-PERFORM.
CLOSE HFILE.
CLOSE TEMPF.
M3PARA.
DISPLAY (5,25) "***STUDENT FORM***" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

DISPLAY (7,20) "ENTER HOSTEL NAME TO BE VACANT: "
ACCEPT THLNO
DISPLAY (9,20) "ENTER ROOM NO. "
ACCEPT TRM
PERFORM RSEARCHPARA.

RSEARCHPARA.
MOVE 0 TO FLAG2
MOVE 'T' TO CHOICE1
OPEN INPUT OUTF.
OPEN OUTPUT TEMPF.
PERFORM UNTIL CHOICE1 = "F"
READ OUTF INTO OUTMAINDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (THLNO = HNAME-O) AND (TRM = ROOMNO-O) AND (FLAG2=0) THEN
DISPLAY " " WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
DISPLAY (4,5) "HOSTEL NAME -->> " HNAME-O
DISPLAY (4,40) "ENTRY DATE -->> "
DISPLAY (4,57) EYY
DISPLAY (4,59) "/"
DISPLAY (4,60) EMM
DISPLAY (4,63) "/"
DISPLAY (4,64) EDD
DISPLAY (6,5) "ROOM NO. -->> "ROOMNO-O
DISPLAY (8,15) "STUDENT NAME -->> " SNAME-O
DISPLAY (10,15) "REG. NO. -->> " REGNO-O
DISPLAY (12,15) "COURSE -->> "COURSE-O
DISPLAY (14,15) "YEAR -->> "YEAR-O
DISPLAY (17,10) "DELETE THIS RECORD? (Y/N)"
ACCEPT RESP
IF RESP = 'Y' THEN
MOVE 1 TO FK
MOVE 1 TO FLAG2
MOVE SNAME-O TO TSNM
DISPLAY (19,10) "RECORD DELETED......"
ELSE
WRITE INTEMPREC FROM OUTMAINDETAILS
END-IF
ELSE
WRITE INTEMPREC FROM OUTMAINDETAILS

END-IF
END-READ
END-PERFORM
CLOSE OUTF
CLOSE TEMPF
IF FLAG2 = 0 THEN
DISPLAY (15,15) "USER DOES NOT WANT TO DELETE THIS RECORD OR " WITH BLANK SCREEN
DISPLAY (16,15) "ERROR IN THE GIVEN DATA"
PERFORM DOCPARA
ELSE
PERFORM MODOFILEPARA
END-IF.
MODOFILEPARA.
OPEN OUTPUT OUTF
OPEN INPUT TEMPF
MOVE 'T' TO CHOICE1
PERFORM UNTIL CHOICE1 = 'F'
READ TEMPF INTO OUTMAINDETAILS
AT END
MOVE 'F' TO CHOICE1
NOT AT END
WRITE OUTMAINREC FROM OUTMAINDETAILS
END-PERFORM
CLOSE OUTF
CLOSE TEMPF
PERFORM MODSFILEPARA.



MODSFILEPARA.
IF FLAG2 = 1 THEN
MOVE 'T' TO CHOICE1
OPEN INPUT SFILE
OPEN OUTPUT TEMPF
PERFORM UNTIL CHOICE1 = "F"
READ SFILE INTO INSTUDENTDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (SNAME IS NOT EQUAL TO TSNM ) THEN
WRITE INTEMPREC FROM INSTUDENTDETAILS
END-IF
END-READ
END-PERFORM
CLOSE SFILE
CLOSE TEMPF
END-IF
PERFORM FILESTUCOPYPARA.
FILESTUCOPYPARA.
OPEN OUTPUT SFILE
OPEN INPUT TEMPF
MOVE 'T' TO CHOICE1
PERFORM UNTIL CHOICE1 = 'F'
READ TEMPF INTO INSTUDENTDETAILS
AT END
MOVE 'F' TO CHOICE1
NOT AT END
WRITE INSTUDENTREC FROM INSTUDENTDETAILS
END-PERFORM
CLOSE SFILE
CLOSE TEMPF
PERFORM MODHFILEPARA.

MODHFILEPARA.
IF FLAG2 = 1 THEN
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
OPEN OUTPUT TEMPF
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (FK = 1) AND ( TRM = ROOMNO) AND (THLNO = HNAME) THEN
COMPUTE AVAILBED = AVAILBED + 1
WRITE INTEMPREC FROM INHOSTELDETAILS
MOVE 0 TO FK
ELSE
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
END-READ
END-PERFORM
CLOSE HFILE
CLOSE TEMPF
END-IF
PERFORM FILECOPYPARA.

M4PARA.
DISPLAY (4,25) "*********CHANGE RECORD FORM*********" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

DISPLAY (6,28) "1.CHANGE THE HOSTEL:"
DISPLAY (8,28) "2.CHANGE THE ROOM:"
DISPLAY (10,28) "3.RETURN TO MAIN MENU:"
DISPLAY (14,28) "ENTER YOUR CHOICE:"
ACCEPT FK
EVALUATE FK
WHEN 1
PERFORM CHPARA
WHEN 2
PERFORM CRPARA
WHEN 3
PERFORM MAINPG-PARA
WHEN OTHER
DISPLAY (16,25) "WRONG CHOICE.........."
DISPLAY (17,25) "PRESS ANY KEY TO CONTINUE......"
ACCEPT ANS
GO TO M4PARA
END-EVALUATE.
CHPARA.
DISPLAY " " WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (6,12) "ENTER STUDENT REG. NO.:"
ACCEPT RGNO
PERFORM DISP1STUPARA.
DISP1STUPARA.
MOVE 0 TO FLAG2
MOVE 'T' TO CHOICE1
OPEN INPUT OUTF
PERFORM UNTIL CHOICE1 = "F"
READ OUTF INTO OUTMAINDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (RGNO = REGNO-O) THEN
DISPLAY " " WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

DISPLAY (4,5) "HOSTEL NAME -->> " HNAME-O
DISPLAY (4,40) ", ROOM NO. -->> "ROOMNO-O
DISPLAY (6,5) "STUDENT NAME -->> " SNAME-O
DISPLAY (6,40) "COURSE -->> "COURSE-O
DISPLAY (8,5) "YEAR -->> "YEAR-O
DISPLAY (10,10) "WANT TO CHANGE THE HOSTEL.? (Y/N)"
ACCEPT RESP
IF RESP = 'Y' THEN
MOVE ROOMNO-O TO TRM
MOVE HNAME-O TO THLNO
DISPLAY (12,12) "ENTER NEW HOSTEL STUDENT WANT:"
ACCEPT NHNM
DISPLAY (14,12) "ENTER NEW ROOM STUDENT WANT:"
ACCEPT NRMNO
MOVE 1 TO FLAG2
END-IF
END-READ
END-PERFORM
CLOSE OUTF
IF FLAG2 = 0 THEN
DISPLAY (12,5) "USER DOES NOT WANT TO CHANGE THE RECORD OR THERE IS SOME MISTAKE IN INPUT" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (14,12) "PRESS ANY KEY TO CONTINUE........"
ACCEPT ANS
GO TO M4PARA
ELSE

PERFORM RCHECK1PARA
END-IF.
RCHECK1PARA.
MOVE 'T' TO CHOICE1
MOVE 0 TO FLAG2
OPEN INPUT HFILE
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (ROOMNO = TRM) AND (HNAME = THLNO) THEN
MOVE TOTALBED TO TTB1
END-IF
IF (ROOMNO = NRMNO) AND (HNAME = NHNM) THEN
&
Was This Post Helpful? 0
  • +
  • -

#8 sakthisridhar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 21-December 08

Re: regarding database connectivity in COBOL

Posted 29 December 2008 - 09:36 PM

View Postn8wxs, on 22 Dec, 2008 - 08:56 PM, said:

what platform, database?


can u say free download for pervasive sql v8 or any database.
At present i have MSSQL SERVER 200 , ORACLE 8I
can it be helpful to use with my cobol program.

the platform i am having is WINDOWS-XP.

can u tell me free download for COBOL.NET FOR WINDOWS-XP PLATFORM WHICH IS AVAILABLE FOR FREE PLEASE SIR.


THE FOLLOWING IS MY OWN CODE THAT HAS NO DATABASE CONNECTIVITY. HOW TO USE DATABASE CONNECTIVITY IN THE FOLLOWING PROGRAM PLEASE TELL.


IT WILL BE HELPFUL TO ME SIR.

PLEASE TELL SOON


[code]
Identification division.
Program-id.hstl.
Environment division.
Input-output section.
File-control.
SELECT HFILE ASSIGN TO "HOSTEL.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT SFILE ASSIGN TO "STUDENT.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT OUTF ASSIGN TO "MAIN.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT TEMPF ASSIGN TO "TEMP.DAT"
ORGANIZATION LINE SEQUENTIAL.

Data division.
File section.
FD HFILE.
01 INHOSTELREC PIC X(80).
FD SFILE.
01 INSTUDENTREC PIC X(80).
FD TEMPF.
01 INTEMPREC PIC X(80).
FD OUTF.
01 OUTMAINREC PIC X(80).

Working-storage section.
01 INHOSTELDETAILS.
02 PIC X(5) VALUE SPACES.
02 HNAME PIC X(15).
02 PIC X(5) VALUE SPACES.
02 ROOMNO PIC 9(3).
02 PIC X(5) VALUE SPACES.
02 TOTALBED PIC 99.
02 PIC X(5) VALUE SPACES.
02 AVAILBED PIC 99.

01 INSTUDENTDETAILS.
02 PIC X(5) VALUE SPACES.
02 SNAME PIC X(15).
02 PIC X(5) VALUE SPACES.
02 REGNO PIC X(10).
02 PIC X(5) VALUE SPACES.
02 COURSE PIC X(5).
02 PIC X(5) VALUE SPACES.
02 YEAR PIC X(10).
02 PIC X(5) VALUE SPACES.
02 FPAID PIC 9(5).


01 OUTMAINDETAILS.
02 PIC X(2) VALUE SPACES.
02 SNAME-O PIC X(15).
02 PIC X(2) VALUE SPACES.
02 REGNO-O PIC X(10).
02 PIC X(2) VALUE SPACES.
02 COURSE-O PIC X(5).
02 PIC X(2) VALUE SPACES.
02 YEAR-O PIC X(10).
02 PIC X(2) VALUE SPACES.
02 HNAME-O PIC X(15).
02 PIC X(2) VALUE SPACES.
02 ROOMNO-O PIC 9(3).
02 PIC X(2) VALUE SPACES.
02 EDATE.
03 EDD PIC 99.
03 EMM PIC 99.
03 EYY PIC 99.
77 MCH PIC 9.
77 CHECK1 PIC 9.
77 FLAG1 PIC 9.
77 NHNM PIC X(15).
77 NRNO PIC 9(3).
77 TTB1 PIC 99.
77 TTB2 PIC 99.
77 CHOICE1 PIC X.
77 TSNM PIC X(15).
77 M2REP PIC X VALUE "Y".
77 M1REP PIC X VALUE "Y".
77 MAINREP PIC X VALUE "Y".
77 ANS PIC X.
77 REPORTCHOICE PIC 9.
77 HLONSCREENCH PIC X VALUE 'T'.
77 HLONSCREENLINE PIC 99 VALUE 1.
77 HLTEMP PIC 99 VALUE 1.
77 HLSCREENPAGE PIC 99 VALUE 1.
77 TRT PIC 9(2).
77 RESP PIC X.
77 THLNO PIC X(15).
77 FLAG2 PIC 9 VALUE 0.
77 TRM PIC 9(3).
77 FK PIC 9 VALUE 0.
77 RGNO PIC X(10).
77 NRMNO PIC 9(3).
77 TLNO PIC 99.
/********* VARIABLE FOR GENERAL USE *********
77 user-name pic x(20).
77 pword pic x(20).
77 countstar pic 9(3).
77 passcount pic 9(1) value 1.
77 CHOICE pic 9.
procedure division.


/****************************** Login Form **********************************

login-form.
perform until passcount >3
add 1 to passcount
display " " with blank screen
perform docpara

display "ллллллллллллллллллллллллллллллллллллл" line 9 col 20
display "л л" line 10 col 20
display "л л" line 11 col 20
display "л USER NAME : л" line 12 col 20
display "л л" line 13 col 20
display "л PASSWORD : л" line 14 col 20
display "л л" line 15 col 20
display "л л" line 16 col 20
display "ллллллллллллллллллллллллллллллллллллл" line 17 col 20
move space to user-name
move space to pword
accept user-name line 12 col 36 with empty-check
accept pword line 14 col 36 with no-echo
if user-name is equal to "NITU" and pword is equal to "NS098"
go to createpara
else if user-name is equal to "KUNJAN" and pword is equal to "KM074"
go to createpara
else if user-name is equal to "KADIR" and pword is equal to "KD085"
go to createpara
else if user-name is equal to "HABEEB" and pword is equal to "HB087"
go to createpara
else if user-name is equal to "PIYUSH" and pword is equal to "PY106"
go to createpara
else display "WRONG USER NAME OR PASSWORD" line 5 col 27 with blink
display " TRY ONCE AGAIN !!! " line 16 col 24 with blink
accept ans
end-if
if passcount>3 then
perform exit-para
end-perform.


/*********************** DESIFN FORM *****************************
CREATEPARA.
DISPLAY (1,2) "WELCOME TO OUR PROJECT" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,26) "* * ***** ***** " WITH REVERSE-VIDEO
DISPLAY (9,26) " * * ** * ** * " WITH REVERSE-VIDEO
DISPLAY (10,26)" * * ** * ** * " WITH REVERSE-VIDEO
DISPLAY (11,26)" * * * * " WITH REVERSE-VIDEO
DISPLAY (12,26)" * ***** ****** " WITH REVERSE-VIDEO
DISPLAY (4,27) " PROJECT FOR"
DISPLAY (5,25) " HOSTEL MANAGEMENT SYSTEM "
DISPLAY (6,24) "---------------------------------"
DISPLAY (22,49) "PRESS ANY KEY TO CONTINUE"
ACCEPT ANS
PERFORM MAINPG-PARA.
/***************** MAIN PAGE FORM *******************

MAINPG-PARA.
PERFORM UNTIL MAINREP = "N"
DISPLAY (4,28) "*** MAIN FORM ***" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
DISPLAY (6,23) "1. ADD HOSTEL INFORMATION "
DISPLAY (8,23) "2. NEW STUDENT ENTRY "
DISPLAY (10,23) "3. DELETE STUDENT RECORD "
DISPLAY (12,23) "4. MODIFY STUDENT RECORD "
DISPLAY (14,23) "5. REPORT GENERATION"
DISPLAY (16,23) "6.EXIT"
DISPLAY (20,23) " ENTER YOUR CHOICE := " WITH BLINK
MOVE SPACES TO MCH
ACCEPT MCH
EVALUATE MCH
WHEN 1
PERFORM M1PARA
WHEN 2
PERFORM M2PARA
WHEN 3
PERFORM M3PARA
WHEN 4
PERFORM M4PARA
WHEN 5
PERFORM MAINREPORTPARA
WHEN 6
PERFORM EXIT-PARA
END-EVALUATE
DISPLAY (22,12) "DO YOU WANT TO CONTINUE THE PROJECT...(Y/N).. = "
MOVE SPACES TO MAINREP
ACCEPT MAINREP
IF MAINREP = "N" THEN
PERFORM EXIT-PARA
END-IF
END-PERFORM.
M1PARA.
PERFORM UNTIL M1REP = "N"
PERFORM M1CHPARA

OPEN EXTEND HFILE

PERFORM M1ENTRY2PARA
CLOSE HFILE
DISPLAY (20,12) "DO YOU WANT TO ENTER MORE RECORDS...(Y/N) := "
ACCEPT M1REP
END-PERFORM.

M1CHPARA.
MOVE 1 TO CHECK1
PERFORM UNTIL CHECK1 = 0
DISPLAY (5,25) "****ADD HOSTEL RECORD FORM****" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,12) "ENTER HOSTEL NAME = "
ACCEPT NHNM
DISPLAY (10,12) "ENTER ROOM NUMBER = "
ACCEPT NRNO
MOVE 0 TO FLAG1
PERFORM M1CHECKPARA

IF FLAG1 = 0 THEN
MOVE 0 TO CHECK1
END-IF
END-PERFORM.

M1CHECKPARA.
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (NHNM = HNAME) AND (NRNO = ROOMNO) THEN
DISPLAY (13,15) "THIS ROOM NO. ALREADY EXIST........" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (17,15) "PLEASE ENTER DIFFERENT CODE"
DISPLAY (20,20) "ENTER ANY KEY TO CONTINUE... "
ACCEPT ANS
MOVE 1 TO FLAG1
MOVE "F" TO CHOICE1
END-IF


END-READ
END-PERFORM
CLOSE HFILE
.
M1ENTRY2PARA.
MOVE NHNM TO HNAME
MOVE NRNO TO ROOMNO
DISPLAY (12,12) "ENTER NUMBER OF BEDS IN THE ROOM = "
ACCEPT TOTALBED
MOVE TOTALBED TO AVAILBED
DISPLAY (14,12) "NEW RECORD ENTERED... "
WRITE INHOSTELREC FROM INHOSTELDETAILS

M2PARA.
PERFORM UNTIL M2REP = "N"
MOVE 0 TO FLAG2
DISPLAY (4,25) "****ADD STUDENT RECORD FORM****" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

OPEN EXTEND SFILE
OPEN EXTEND OUTF
PERFORM M2ENTRYPARA
CLOSE SFILE
CLOSE OUTF
DISPLAY (20,12) "DO YOU WANT TO ENTER MORE RECORDS...(Y/N) := "
ACCEPT M2REP
END-PERFORM.
M2ENTRYPARA.
DISPLAY(6,12) "ENTER STUDENT NAME: "
ACCEPT SNAME
DISPLAY(8,12) "ENTER REGISTRATION NUMBER: "
ACCEPT REGNO
DISPLAY(10,12) "ENTER COURSE: "
ACCEPT COURSE
DISPLAY (12,12) "ENTER YEAR: "
ACCEPT YEAR
DISPLAY(14,12) "ENTER FEE PAID: "
ACCEPT FPAID
DISPLAY (16,12) "ENTER HOSTEL NAME STUDENT WANT: "
ACCEPT THLNO
PERFORM M2FEECHECKPARA.

M2FEECHECKPARA.
IF FPAID = 55000 THEN
MOVE 1 TO TRT.
IF FPAID = 50000 THEN
MOVE 2 TO TRT.
IF FPAID = 45000 THEN
MOVE 3 TO TRT.
IF FPAID = 40000 THEN
MOVE 4 TO TRT.
IF FPAID = 35000 THEN
MOVE 10 TO TRT.

PERFORM HOSTELAVAILPARA.
HOSTELAVAILPARA.
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
OPEN OUTPUT TEMPF
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (FLAG2 = 0) AND (THLNO = HNAME) AND (TRT = TOTALBED) THEN
IF (AVAILBED > 0) THEN
MOVE 1 TO FLAG2
MOVE ROOMNO TO TRM
COMPUTE AVAILBED = AVAILBED - 1
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
ELSE
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
END-READ
END-PERFORM
CLOSE HFILE
CLOSE TEMPF
PERFORM MAINENPARA.
MAINENPARA.
IF FLAG2 = 1 THEN
DISPLAY (14,12) "NEW RECORD ENTERED... " WITH BLANK SCREEN
PERFORM DOCPARA
WRITE INSTUDENTREC FROM INSTUDENTDETAILS
MOVE SNAME TO SNAME-O
MOVE REGNO TO REGNO-O
MOVE COURSE TO COURSE-O
MOVE YEAR TO YEAR-O
MOVE THLNO TO HNAME-O
MOVE TRM TO ROOMNO-O
ACCEPT EDATE FROM DATE
WRITE OUTMAINREC FROM OUTMAINDETAILS
DISPLAY (8,10) "STUDENT HAS GOT ROOM NO: " WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,38)TRM
DISPLAY (9,10) "IN HOSTEL "
DISPLAY (9,21) THLNO
PERFORM FILECOPYPARA
ELSE
DISPLAY (6,12) "ROOM IS NOT AVAILABLE IN THIS HOSTEL TRY FOR ANOTHER ONE " WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (20,20) "ENTER ANY KEY TO CONTINUE... "
ACCEPT ANS
.
FILECOPYPARA.
OPEN OUTPUT HFILE.
OPEN INPUT TEMPF.
MOVE 'T' TO CHOICE1
PERFORM UNTIL CHOICE1 = 'F'
READ TEMPF INTO INHOSTELDETAILS
AT END
MOVE 'F' TO CHOICE1
NOT AT END
WRITE INHOSTELREC FROM INHOSTELDETAILS
END-PERFORM.
CLOSE HFILE.
CLOSE TEMPF.
M3PARA.
DISPLAY (5,25) "***STUDENT FORM***" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

DISPLAY (7,20) "ENTER HOSTEL NAME TO BE VACANT: "
ACCEPT THLNO
DISPLAY (9,20) "ENTER ROOM NO. "
ACCEPT TRM
PERFORM RSEARCHPARA.

RSEARCHPARA.
MOVE 0 TO FLAG2
MOVE 'T' TO CHOICE1
OPEN INPUT OUTF.
OPEN OUTPUT TEMPF.
PERFORM UNTIL CHOICE1 = "F"
READ OUTF INTO OUTMAINDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (THLNO = HNAME-O) AND (TRM = ROOMNO-O) AND (FLAG2=0) THEN
DISPLAY " " WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
DISPLAY (4,5) "HOSTEL NAME -->> " HNAME-O
DISPLAY (4,40) "ENTRY DATE -->> "
DISPLAY (4,57) EYY
DISPLAY (4,59) "/"
DISPLAY (4,60) EMM
DISPLAY (4,63) "/"
DISPLAY (4,64) EDD
DISPLAY (6,5) "ROOM NO. -->> "ROOMNO-O
DISPLAY (8,15) "STUDENT NAME -->> " SNAME-O
DISPLAY (10,15) "REG. NO. -->> " REGNO-O
DISPLAY (12,15) "COURSE -->> "COURSE-O
DISPLAY (14,15) "YEAR -->> "YEAR-O
DISPLAY (17,10) "DELETE THIS RECORD? (Y/N)"
ACCEPT RESP
IF RESP = 'Y' THEN
MOVE 1 TO FK
MOVE 1 TO FLAG2
MOVE SNAME-O TO TSNM
DISPLAY (19,10) "RECORD DELETED......"
ELSE
WRITE INTEMPREC FROM OUTMAINDETAILS
END-IF
ELSE
WRITE INTEMPREC FROM OUTMAINDETAILS

END-IF
END-READ
END-PERFORM
CLOSE OUTF
CLOSE TEMPF
IF FLAG2 = 0 THEN
DISPLAY (15,15) "USER DOES NOT WANT TO DELETE THIS RECORD OR " WITH BLANK SCREEN
DISPLAY (16,15) "ERROR IN THE GIVEN DATA"
PERFORM DOCPARA
ELSE
PERFORM MODOFILEPARA
END-IF.
MODOFILEPARA.
OPEN OUTPUT OUTF
OPEN INPUT TEMPF
MOVE 'T' TO CHOICE1
PERFORM UNTIL CHOICE1 = 'F'
READ TEMPF INTO OUTMAINDETAILS
AT END
MOVE 'F' TO CHOICE1
NOT AT END
WRITE OUTMAINREC FROM OUTMAINDETAILS
END-PERFORM
CLOSE OUTF
CLOSE TEMPF
PERFORM MODSFILEPARA.



MODSFILEPARA.
IF FLAG2 = 1 THEN
MOVE 'T' TO CHOICE1
OPEN INPUT SFILE
OPEN OUTPUT TEMPF
PERFORM UNTIL CHOICE1 = "F"
READ SFILE INTO INSTUDENTDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (SNAME IS NOT EQUAL TO TSNM ) THEN
WRITE INTEMPREC FROM INSTUDENTDETAILS
END-IF
END-READ
END-PERFORM
CLOSE SFILE
CLOSE TEMPF
END-IF
PERFORM FILESTUCOPYPARA.
FILESTUCOPYPARA.
OPEN OUTPUT SFILE
OPEN INPUT TEMPF
MOVE 'T' TO CHOICE1
PERFORM UNTIL CHOICE1 = 'F'
READ TEMPF INTO INSTUDENTDETAILS
AT END
MOVE 'F' TO CHOICE1
NOT AT END
WRITE INSTUDENTREC FROM INSTUDENTDETAILS
END-PERFORM
CLOSE SFILE
CLOSE TEMPF
PERFORM MODHFILEPARA.

MODHFILEPARA.
IF FLAG2 = 1 THEN
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
OPEN OUTPUT TEMPF
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (FK = 1) AND ( TRM = ROOMNO) AND (THLNO = HNAME) THEN
COMPUTE AVAILBED = AVAILBED + 1
WRITE INTEMPREC FROM INHOSTELDETAILS
MOVE 0 TO FK
ELSE
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
END-READ
END-PERFORM
CLOSE HFILE
CLOSE TEMPF
END-IF
PERFORM FILECOPYPARA.

M4PARA.
DISPLAY (4,25) "*********CHANGE RECORD FORM*********" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

DISPLAY (6,28) "1.CHANGE THE HOSTEL:"
DISPLAY (8,28) "2.CHANGE THE ROOM:"
DISPLAY (10,28) "3.RETURN TO MAIN MENU:"
DISPLAY (14,28) "ENTER YOUR CHOICE:"
ACCEPT FK
EVALUATE FK
WHEN 1
PERFORM CHPARA
WHEN 2
PERFORM CRPARA
WHEN 3
PERFORM MAINPG-PARA
WHEN OTHER
DISPLAY (16,25) "WRONG CHOICE.........."
DISPLAY (17,25) "PRESS ANY KEY TO CONTINUE......"
ACCEPT ANS
GO TO M4PARA
END-EVALUATE.
CHPARA.
DISPLAY " " WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (6,12) "ENTER STUDENT REG. NO.:"
ACCEPT RGNO
PERFORM DISP1STUPARA.
DISP1STUPARA.
MOVE 0 TO FLAG2
MOVE 'T' TO CHOICE1
OPEN INPUT OUTF
PERFORM UNTIL CHOICE1 = "F"
READ OUTF INTO OUTMAINDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (RGNO = REGNO-O) THEN
DISPLAY " " WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

DISPLAY (4,5) "HOSTEL NAME -->> " HNAME-O
DISPLAY (4,40) ", ROOM NO. -->> "ROOMNO-O
DISPLAY (6,5) "STUDENT NAME -->> " SNAME-O
DISPLAY (6,40) "COURSE -->> "COURSE-O
DISPLAY (8,5) "YEAR -->> "YEAR-O
DISPLAY (10,10) "WANT TO CHANGE THE HOSTEL.? (Y/N)"
ACCEPT RESP
IF RESP = 'Y' THEN
MOVE ROOMNO-O TO TRM
MOVE HNAME-O TO THLNO
DISPLAY (12,12) "ENTER NEW HOSTEL STUDENT WANT:"
ACCEPT NHNM
DISPLAY (14,12) "ENTER NEW ROOM STUDENT WANT:"
ACCEPT NRMNO
MOVE 1 TO FLAG2
END-IF
END-READ
END-PERFORM
CLOSE OUTF
IF FLAG2 = 0 THEN
DISPLAY (12,5) "USER DOES NOT WANT TO CHANGE THE RECORD OR THERE IS SOME MISTAKE IN INPUT" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (14,12) "PRESS ANY KEY TO CONTINUE........"
ACCEPT ANS
GO TO M4PARA
ELSE

PERFORM RCHECK1PARA
END-IF.
RCHECK1PARA.
MOVE 'T' TO CHOICE1
MOVE 0 TO FLAG2
OPEN INPUT HFILE
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (ROOMNO = TRM) AND (HNAME = THLNO) THEN
MOVE TOTALBED TO TTB1
END-IF
IF (ROOMNO = NRMNO) AND (HNAME = NHNM) THEN
MOVE TOTALBED TO TTB2
END-IF
IF (ROOMNO = NRMNO) AND (HNAME = NHNM) AND (AVAILBED = 0) THEN
DISPLAY (13,12) "GIVEN ROOM NO. IS FULL."
ACCEPT ANS
MOVE 1 TO FLAG2

END-IF

END-READ
IF FLAG2 = 1 THEN
DISPLAY (17,12) "INVALID HOSTEL NAME OR ROOM NO."
MOVE 1 TO FLAG2
ACCEPT ANS
END-IF
Was This Post Helpful? 0
  • +
  • -

#9 sakthisridhar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 21-December 08

Re: regarding database connectivity in COBOL

Posted 29 December 2008 - 09:48 PM

[quote name='sakthisridhar' date='29 Dec, 2008 - 08:36 PM' post='500581']

View Postn8wxs, on 22 Dec, 2008 - 08:56 PM, said:

what platform, database?


can u say free download for pervasive sql v8 or any database.
At present i have MSSQL SERVER 200 , ORACLE 8I
can it be helpful to use with my cobol program.

the platform i am having is WINDOWS-XP.

can u tell me free download for COBOL.NET FOR WINDOWS-XP PLATFORM WHICH IS AVAILABLE FOR FREE PLEASE SIR.


THE FOLLOWING IS MY OWN CODE THAT HAS NO DATABASE CONNECTIVITY. HOW TO USE DATABASE CONNECTIVITY IN THE FOLLOWING PROGRAM PLEASE TELL.


IT WILL BE HELPFUL TO ME SIR.

PLEASE TELL SOON


[code]
Identification division.
Program-id.hstl.
Environment division.
Input-output section.
File-control.
SELECT HFILE ASSIGN TO "HOSTEL.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT SFILE ASSIGN TO "STUDENT.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT OUTF ASSIGN TO "MAIN.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT TEMPF ASSIGN TO "TEMP.DAT"
ORGANIZATION LINE SEQUENTIAL.

Data division.
File section.
FD HFILE.
01 INHOSTELREC PIC X(80).
FD SFILE.
01 INSTUDENTREC PIC X(80).
FD TEMPF.
01 INTEMPREC PIC X(80).
FD OUTF.
01 OUTMAINREC PIC X(80).

Working-storage section.
01 INHOSTELDETAILS.
02 PIC X(5) VALUE SPACES.
02 HNAME PIC X(15).
02 PIC X(5) VALUE SPACES.
02 ROOMNO PIC 9(3).
02 PIC X(5) VALUE SPACES.
02 TOTALBED PIC 99.
02 PIC X(5) VALUE SPACES.
02 AVAILBED PIC 99.

01 INSTUDENTDETAILS.
02 PIC X(5) VALUE SPACES.
02 SNAME PIC X(15).
02 PIC X(5) VALUE SPACES.
02 REGNO PIC X(10).
02 PIC X(5) VALUE SPACES.
02 COURSE PIC X(5).
02 PIC X(5) VALUE SPACES.
02 YEAR PIC X(10).
02 PIC X(5) VALUE SPACES.
02 FPAID PIC 9(5).


01 OUTMAINDETAILS.
02 PIC X(2) VALUE SPACES.
02 SNAME-O PIC X(15).
02 PIC X(2) VALUE SPACES.
02 REGNO-O PIC X(10).
02 PIC X(2) VALUE SPACES.
02 COURSE-O PIC X(5).
02 PIC X(2) VALUE SPACES.
02 YEAR-O PIC X(10).
02 PIC X(2) VALUE SPACES.
02 HNAME-O PIC X(15).
02 PIC X(2) VALUE SPACES.
02 ROOMNO-O PIC 9(3).
02 PIC X(2) VALUE SPACES.
02 EDATE.
03 EDD PIC 99.
03 EMM PIC 99.
03 EYY PIC 99.
77 MCH PIC 9.
77 CHECK1 PIC 9.
77 FLAG1 PIC 9.
77 NHNM PIC X(15).
77 NRNO PIC 9(3).
77 TTB1 PIC 99.
77 TTB2 PIC 99.
77 CHOICE1 PIC X.
77 TSNM PIC X(15).
77 M2REP PIC X VALUE "Y".
77 M1REP PIC X VALUE "Y".
77 MAINREP PIC X VALUE "Y".
77 ANS PIC X.
77 REPORTCHOICE PIC 9.
77 HLONSCREENCH PIC X VALUE 'T'.
77 HLONSCREENLINE PIC 99 VALUE 1.
77 HLTEMP PIC 99 VALUE 1.
77 HLSCREENPAGE PIC 99 VALUE 1.
77 TRT PIC 9(2).
77 RESP PIC X.
77 THLNO PIC X(15).
77 FLAG2 PIC 9 VALUE 0.
77 TRM PIC 9(3).
77 FK PIC 9 VALUE 0.
77 RGNO PIC X(10).
77 NRMNO PIC 9(3).
77 TLNO PIC 99.
/********* VARIABLE FOR GENERAL USE *********
77 user-name pic x(20).
77 pword pic x(20).
77 countstar pic 9(3).
77 passcount pic 9(1) value 1.
77 CHOICE pic 9.
procedure division.


/****************************** Login Form **********************************

login-form.
perform until passcount >3
add 1 to passcount
display " " with blank screen
perform docpara

display "ллллллллллллллллллллллллллллллллллллл" line 9 col 20
display "л л" line 10 col 20
display "л л" line 11 col 20
display "л USER NAME : л" line 12 col 20
display "л л" line 13 col 20
display "л PASSWORD : л" line 14 col 20
display "л л" line 15 col 20
display "л л" line 16 col 20
display "ллллллллллллллллллллллллллллллллллллл" line 17 col 20
move space to user-name
move space to pword
accept user-name line 12 col 36 with empty-check
accept pword line 14 col 36 with no-echo
if user-name is equal to "NITU" and pword is equal to "NS098"
go to createpara
else if user-name is equal to "KUNJAN" and pword is equal to "KM074"
go to createpara
else if user-name is equal to "KADIR" and pword is equal to "KD085"
go to createpara
else if user-name is equal to "HABEEB" and pword is equal to "HB087"
go to createpara
else if user-name is equal to "PIYUSH" and pword is equal to "PY106"
go to createpara
else display "WRONG USER NAME OR PASSWORD" line 5 col 27 with blink
display " TRY ONCE AGAIN !!! " line 16 col 24 with blink
accept ans
end-if
if passcount>3 then
perform exit-para
end-perform.


/*********************** DESIFN FORM *****************************
CREATEPARA.
DISPLAY (1,2) "WELCOME TO OUR PROJECT" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,26) "* * ***** ***** " WITH REVERSE-VIDEO
DISPLAY (9,26) " * * ** * ** * " WITH REVERSE-VIDEO
DISPLAY (10,26)" * * ** * ** * " WITH REVERSE-VIDEO
DISPLAY (11,26)" * * * * " WITH REVERSE-VIDEO
DISPLAY (12,26)" * ***** ****** " WITH REVERSE-VIDEO
DISPLAY (4,27) " PROJECT FOR"
DISPLAY (5,25) " HOSTEL MANAGEMENT SYSTEM "
DISPLAY (6,24) "---------------------------------"
DISPLAY (22,49) "PRESS ANY KEY TO CONTINUE"
ACCEPT ANS
PERFORM MAINPG-PARA.
/***************** MAIN PAGE FORM *******************

MAINPG-PARA.
PERFORM UNTIL MAINREP = "N"
DISPLAY (4,28) "*** MAIN FORM ***" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
DISPLAY (6,23) "1. ADD HOSTEL INFORMATION "
DISPLAY (8,23) "2. NEW STUDENT ENTRY "
DISPLAY (10,23) "3. DELETE STUDENT RECORD "
DISPLAY (12,23) "4. MODIFY STUDENT RECORD "
DISPLAY (14,23) "5. REPORT GENERATION"
DISPLAY (16,23) "6.EXIT"
DISPLAY (20,23) " ENTER YOUR CHOICE := " WITH BLINK
MOVE SPACES TO MCH
ACCEPT MCH
EVALUATE MCH
WHEN 1
PERFORM M1PARA
WHEN 2
PERFORM M2PARA
WHEN 3
PERFORM M3PARA
WHEN 4
PERFORM M4PARA
WHEN 5
PERFORM MAINREPORTPARA
WHEN 6
PERFORM EXIT-PARA
END-EVALUATE
DISPLAY (22,12) "DO YOU WANT TO CONTINUE THE PROJECT...(Y/N).. = "
MOVE SPACES TO MAINREP
ACCEPT MAINREP
IF MAINREP = "N" THEN
PERFORM EXIT-PARA
END-IF
END-PERFORM.
M1PARA.
PERFORM UNTIL M1REP = "N"
PERFORM M1CHPARA

OPEN EXTEND HFILE

PERFORM M1ENTRY2PARA
CLOSE HFILE
DISPLAY (20,12) "DO YOU WANT TO ENTER MORE RECORDS...(Y/N) := "
ACCEPT M1REP
END-PERFORM.

M1CHPARA.
MOVE 1 TO CHECK1
PERFORM UNTIL CHECK1 = 0
DISPLAY (5,25) "****ADD HOSTEL RECORD FORM****" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,12) "ENTER HOSTEL NAME = "
ACCEPT NHNM
DISPLAY (10,12) "ENTER ROOM NUMBER = "
ACCEPT NRNO
MOVE 0 TO FLAG1
PERFORM M1CHECKPARA

IF FLAG1 = 0 THEN
MOVE 0 TO CHECK1
END-IF
END-PERFORM.

M1CHECKPARA.
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (NHNM = HNAME) AND (NRNO = ROOMNO) THEN
DISPLAY (13,15) "THIS ROOM NO. ALREADY EXIST........" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (17,15) "PLEASE ENTER DIFFERENT CODE"
DISPLAY (20,20) "ENTER ANY KEY TO CONTINUE... "
ACCEPT ANS
MOVE 1 TO FLAG1
MOVE "F" TO CHOICE1
END-IF


END-READ
END-PERFORM
CLOSE HFILE
.
M1ENTRY2PARA.
MOVE NHNM TO HNAME
MOVE NRNO TO ROOMNO
DISPLAY (12,12) "ENTER NUMBER OF BEDS IN THE ROOM = "
ACCEPT TOTALBED
MOVE TOTALBED TO AVAILBED
DISPLAY (14,12) "NEW RECORD ENTERED... "
WRITE INHOSTELREC FROM INHOSTELDETAILS

M2PARA.
PERFORM UNTIL M2REP = "N"
MOVE 0 TO FLAG2
DISPLAY (4,25) "****ADD STUDENT RECORD FORM****" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

OPEN EXTEND SFILE
OPEN EXTEND OUTF
PERFORM M2ENTRYPARA
CLOSE SFILE
CLOSE OUTF
DISPLAY (20,12) "DO YOU WANT TO ENTER MORE RECORDS...(Y/N) := "
ACCEPT M2REP
END-PERFORM.
M2ENTRYPARA.
DISPLAY(6,12) "ENTER STUDENT NAME: "
ACCEPT SNAME
DISPLAY(8,12) "ENTER REGISTRATION NUMBER: "
ACCEPT REGNO
DISPLAY(10,12) "ENTER COURSE: "
ACCEPT COURSE
DISPLAY (12,12) "ENTER YEAR: "
ACCEPT YEAR
DISPLAY(14,12) "ENTER FEE PAID: "
ACCEPT FPAID
DISPLAY (16,12) "ENTER HOSTEL NAME STUDENT WANT: "
ACCEPT THLNO
PERFORM M2FEECHECKPARA.

M2FEECHECKPARA.
IF FPAID = 55000 THEN
MOVE 1 TO TRT.
IF FPAID = 50000 THEN
MOVE 2 TO TRT.
IF FPAID = 45000 THEN
MOVE 3 TO TRT.
IF FPAID = 40000 THEN
MOVE 4 TO TRT.
IF FPAID = 35000 THEN
MOVE 10 TO TRT.

PERFORM HOSTELAVAILPARA.
HOSTELAVAILPARA.
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
OPEN OUTPUT TEMPF
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (FLAG2 = 0) AND (THLNO = HNAME) AND (TRT = TOTALBED) THEN
IF (AVAILBED > 0) THEN
MOVE 1 TO FLAG2
MOVE ROOMNO TO TRM
COMPUTE AVAILBED = AVAILBED - 1
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
ELSE
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
END-READ
END-PERFORM
CLOSE HFILE
CLOSE TEMPF
PERFORM MAINENPARA.
MAINENPARA.
IF FLAG2 = 1 THEN
DISPLAY (14,12) "NEW RECORD ENTERED... " WITH BLANK SCREEN
PERFORM DOCPARA
WRITE INSTUDENTREC FROM INSTUDENTDETAILS
MOVE SNAME TO SNAME-O
MOVE REGNO TO REGNO-O
MOVE COURSE TO COURSE-O
MOVE YEAR TO YEAR-O
MOVE THLNO TO HNAME-O
MOVE TRM TO ROOMNO-O
ACCEPT EDATE FROM DATE
WRITE OUTMAINREC FROM OUTMAINDETAILS
DISPLAY (8,10) "STUDENT HAS GOT ROOM NO: " WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,38)TRM
DISPLAY (9,10) "IN HOSTEL "
DISPLAY (9,21) THLNO
PERFORM FILECOPYPARA
ELSE
DISPLAY (6,12) "ROOM IS NOT AVAILABLE IN THIS HOSTEL TRY FOR ANOTHER ONE " WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (20,20) "ENTER ANY KEY TO CONTINUE... "
ACCEPT ANS
.
FILECOPYPARA.
OPEN OUTPUT HFILE.
OPEN INPUT TEMPF.
MOVE 'T' TO CHOICE1
PERFORM UNTIL CHOICE1 = 'F'
READ TEMPF INTO INHOSTELDETAILS
AT END
MOVE 'F' TO CHOICE1
NOT AT END
WRITE INHOSTELREC FROM INHOSTELDETAILS
END-PERFORM.
CLOSE HFILE.
CLOSE TEMPF.
M3PARA.
DISPLAY (5,25) "***STUDENT FORM***" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

DISPLAY (7,20) "ENTER HOSTEL NAME TO BE VACANT: "
ACCEPT THLNO
DISPLAY (9,20) "ENTER ROOM NO. "
ACCEPT TRM
PERFORM RSEARCHPARA.

RSEARCHPARA.
MOVE 0 TO FLAG2
MOVE 'T' TO CHOICE1
OPEN INPUT OUTF.
OPEN OUTPUT TEMPF.
PERFORM UNTIL CHOICE1 = "F"
READ OUTF INTO OUTMAINDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (THLNO = HNAME-O) AND (TRM = ROOMNO-O) AND (FLAG2=0) THEN
DISPLAY " " WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
DISPLAY (4,5) "HOSTEL NAME -->> " HNAME-O
DISPLAY (4,40) "ENTRY DATE -->> "
DISPLAY (4,57) EYY
DISPLAY (4,59) "/"
DISPLAY (4,60) EMM
DISPLAY (4,63) "/"
DISPLAY (4,64) EDD
DISPLAY (6,5) "ROOM NO. -->> "ROOMNO-O
DISPLAY (8,15) "STUDENT NAME -->> " SNAME-O
DISPLAY (10,15) "REG. NO. -->> " REGNO-O
DISPLAY (12,15) "COURSE -->> "COURSE-O
DISPLAY (14,15) "YEAR -->> "YEAR-O
DISPLAY (17,10) "DELETE THIS RECORD? (Y/N)"
ACCEPT RESP
IF RESP = 'Y' THEN
MOVE 1 TO FK
MOVE 1 TO FLAG2
MOVE SNAME-O TO TSNM
DISPLAY (19,10) "RECORD DELETED......"
ELSE
WRITE INTEMPREC FROM OUTMAINDETAILS
END-IF
ELSE
WRITE INTEMPREC FROM OUTMAINDETAILS

END-IF
END-READ
END-PERFORM
CLOSE OUTF
CLOSE TEMPF
IF FLAG2 = 0 THEN
DISPLAY (15,15) "USER DOES NOT WANT TO DELETE THIS RECORD OR " WITH BLANK SCREEN
DISPLAY (16,15) "ERROR IN THE GIVEN DATA"
PERFORM DOCPARA
ELSE
PERFORM MODOFILEPARA
END-IF.
MODOFILEPARA.
OPEN OUTPUT OUTF
OPEN INPUT TEMPF
MOVE 'T' TO CHOICE1
PERFORM UNTIL CHOICE1 = 'F'
READ TEMPF INTO OUTMAINDETAILS
AT END
MOVE 'F' TO CHOICE1
NOT AT END
WRITE OUTMAINREC FROM OUTMAINDETAILS
END-PERFORM
CLOSE OUTF
CLOSE TEMPF
PERFORM MODSFILEPARA.



MODSFILEPARA.
IF FLAG2 = 1 THEN
MOVE 'T' TO CHOICE1
OPEN INPUT SFILE
OPEN OUTPUT TEMPF
PERFORM UNTIL CHOICE1 = "F"
READ SFILE INTO INSTUDENTDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (SNAME IS NOT EQUAL TO TSNM ) THEN
WRITE INTEMPREC FROM INSTUDENTDETAILS
END-IF
END-READ
END-PERFORM
CLOSE SFILE
CLOSE TEMPF
END-IF
PERFORM FILESTUCOPYPARA.
FILESTUCOPYPARA.
OPEN OUTPUT SFILE
OPEN INPUT TEMPF
MOVE 'T' TO CHOICE1
PERFORM UNTIL CHOICE1 = 'F'
READ TEMPF INTO INSTUDENTDETAILS
AT END
MOVE 'F' TO CHOICE1
NOT AT END
WRITE INSTUDENTREC FROM INSTUDENTDETAILS
END-PERFORM
CLOSE SFILE
CLOSE TEMPF
PERFORM MODHFILEPARA.

MODHFILEPARA.
IF FLAG2 = 1 THEN
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
OPEN OUTPUT TEMPF
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (FK = 1) AND ( TRM = ROOMNO) AND (THLNO = HNAME) THEN
COMPUTE AVAILBED = AVAILBED + 1
WRITE INTEMPREC FROM INHOSTELDETAILS
MOVE 0 TO FK
ELSE
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
END-READ
END-PERFORM
CLOSE HFILE
CLOSE TEMPF
END-IF
PERFORM FILECOPYPARA.

M4PARA.
DISPLAY (4,25) "*********CHANGE RECORD FORM*********" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

DISPLAY (6,28) "1.CHANGE THE HOSTEL:"
DISPLAY (8,28) "2.CHANGE THE ROOM:"
DISPLAY (10,28) "3.RETURN TO MAIN MENU:"
DISPLAY (14,28) "ENTER YOUR CHOICE:"
ACCEPT FK
EVALUATE FK
WHEN 1
PERFORM CHPARA
WHEN 2
PERFORM CRPARA
WHEN 3
PERFORM MAINPG-PARA
WHEN OTHER
DISPLAY (16,25) "WRONG CHOICE.........."
DISPLAY (17,25) "PRESS ANY KEY TO CONTINUE......"
ACCEPT ANS
GO TO M4PARA
END-EVALUATE.
CHPARA.
DISPLAY " " WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (6,12) "ENTER STUDENT REG. NO.:"
ACCEPT RGNO
PERFORM DISP1STUPARA.
DISP1STUPARA.
MOVE 0 TO FLAG2
MOVE 'T' TO CHOICE1
OPEN INPUT OUTF
PERFORM UNTIL CHOICE1 = "F"
READ OUTF INTO OUTMAINDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (RGNO = REGNO-O) THEN
DISPLAY " " WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

DISPLAY (4,5) "HOSTEL NAME -->> " HNAME-O
DISPLAY (4,40) ", ROOM NO. -->> "ROOMNO-O
DISPLAY (6,5) "STUDENT NAME -->> " SNAME-O
DISPLAY (6,40) "COURSE -->> "COURSE-O
DISPLAY (8,5) "YEAR -->> "YEAR-O
DISPLAY (10,10) "WANT TO CHANGE THE HOSTEL.? (Y/N)"
ACCEPT RESP
IF RESP = 'Y' THEN
MOVE ROOMNO-O TO TRM
MOVE HNAME-O TO THLNO
DISPLAY (12,12) "ENTER NEW HOSTEL STUDENT WANT:"
ACCEPT NHNM
DISPLAY (14,12) "ENTER NEW ROOM STUDENT WANT:"
ACCEPT NRMNO
MOVE 1 TO FLAG2
END-IF
END-READ
END-PERFORM
CLOSE OUTF
IF FLAG2 = 0 THEN
DISPLAY (12,5) "USER DOES NOT WANT TO CHANGE THE RECORD OR THERE IS SOME MISTAKE IN INPUT" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (14,12) "PRESS ANY KEY TO CONTINUE........"
ACCEPT ANS
GO TO M4PARA
ELSE

PERFORM RCHECK1PARA
END-IF.
RCHECK1PARA.
MOVE 'T' TO CHOICE1
MOVE 0 TO FLAG2
OPEN INPUT HFILE
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (ROOMNO = TRM) AND (HNAME = THLNO) THEN
MOVE TOTALBED TO TTB1
END-IF
IF (ROOMNO = NRMNO) AND (HNAME = NHNM) THEN
MOVE TOTALBED TO TTB2
END-IF
IF (ROOMNO = NRMNO) AND (HNAME = NHNM) AND (AVAILBED = 0) THEN
DISPLAY (13,12) "GIVEN ROOM NO. IS FULL."
ACCEPT ANS
MOVE 1 TO FLAG2

END-IF

END-READ
IF FLAG2 = 1 THEN
DISPLAY (17,12) "INVALID HOSTEL NAME OR ROOM NO."
MOVE 1 TO FLAG2
ACCEPT ANS
END-IF

[code]

[quote name='sakthisridhar' date='29 Dec, 2008 - 08:36 PM' post='500581']

View Postn8wxs, on 22 Dec, 2008 - 08:56 PM, said:

what platform, database?


can u say free download for pervasive sql v8 or any database.
At present i have MSSQL SERVER 200 , ORACLE 8I
can it be helpful to use with my cobol program.

the platform i am having is WINDOWS-XP.

can u tell me free download for COBOL.NET FOR WINDOWS-XP PLATFORM WHICH IS AVAILABLE FOR FREE PLEASE SIR.


THE FOLLOWING IS MY OWN CODE THAT HAS NO DATABASE CONNECTIVITY. HOW TO USE DATABASE CONNECTIVITY IN THE FOLLOWING PROGRAM PLEASE TELL.


IT WILL BE HELPFUL TO ME SIR.

PLEASE TELL SOON


[code]
Identification division.
Program-id.hstl.
Environment division.
Input-output section.
File-control.
SELECT HFILE ASSIGN TO "HOSTEL.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT SFILE ASSIGN TO "STUDENT.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT OUTF ASSIGN TO "MAIN.DAT"
ORGANIZATION LINE SEQUENTIAL.
SELECT TEMPF ASSIGN TO "TEMP.DAT"
ORGANIZATION LINE SEQUENTIAL.

Data division.
File section.
FD HFILE.
01 INHOSTELREC PIC X(80).
FD SFILE.
01 INSTUDENTREC PIC X(80).
FD TEMPF.
01 INTEMPREC PIC X(80).
FD OUTF.
01 OUTMAINREC PIC X(80).

Working-storage section.
01 INHOSTELDETAILS.
02 PIC X(5) VALUE SPACES.
02 HNAME PIC X(15).
02 PIC X(5) VALUE SPACES.
02 ROOMNO PIC 9(3).
02 PIC X(5) VALUE SPACES.
02 TOTALBED PIC 99.
02 PIC X(5) VALUE SPACES.
02 AVAILBED PIC 99.

01 INSTUDENTDETAILS.
02 PIC X(5) VALUE SPACES.
02 SNAME PIC X(15).
02 PIC X(5) VALUE SPACES.
02 REGNO PIC X(10).
02 PIC X(5) VALUE SPACES.
02 COURSE PIC X(5).
02 PIC X(5) VALUE SPACES.
02 YEAR PIC X(10).
02 PIC X(5) VALUE SPACES.
02 FPAID PIC 9(5).


01 OUTMAINDETAILS.
02 PIC X(2) VALUE SPACES.
02 SNAME-O PIC X(15).
02 PIC X(2) VALUE SPACES.
02 REGNO-O PIC X(10).
02 PIC X(2) VALUE SPACES.
02 COURSE-O PIC X(5).
02 PIC X(2) VALUE SPACES.
02 YEAR-O PIC X(10).
02 PIC X(2) VALUE SPACES.
02 HNAME-O PIC X(15).
02 PIC X(2) VALUE SPACES.
02 ROOMNO-O PIC 9(3).
02 PIC X(2) VALUE SPACES.
02 EDATE.
03 EDD PIC 99.
03 EMM PIC 99.
03 EYY PIC 99.
77 MCH PIC 9.
77 CHECK1 PIC 9.
77 FLAG1 PIC 9.
77 NHNM PIC X(15).
77 NRNO PIC 9(3).
77 TTB1 PIC 99.
77 TTB2 PIC 99.
77 CHOICE1 PIC X.
77 TSNM PIC X(15).
77 M2REP PIC X VALUE "Y".
77 M1REP PIC X VALUE "Y".
77 MAINREP PIC X VALUE "Y".
77 ANS PIC X.
77 REPORTCHOICE PIC 9.
77 HLONSCREENCH PIC X VALUE 'T'.
77 HLONSCREENLINE PIC 99 VALUE 1.
77 HLTEMP PIC 99 VALUE 1.
77 HLSCREENPAGE PIC 99 VALUE 1.
77 TRT PIC 9(2).
77 RESP PIC X.
77 THLNO PIC X(15).
77 FLAG2 PIC 9 VALUE 0.
77 TRM PIC 9(3).
77 FK PIC 9 VALUE 0.
77 RGNO PIC X(10).
77 NRMNO PIC 9(3).
77 TLNO PIC 99.
/********* VARIABLE FOR GENERAL USE *********
77 user-name pic x(20).
77 pword pic x(20).
77 countstar pic 9(3).
77 passcount pic 9(1) value 1.
77 CHOICE pic 9.
procedure division.


/****************************** Login Form **********************************

login-form.
perform until passcount >3
add 1 to passcount
display " " with blank screen
perform docpara

display "ллллллллллллллллллллллллллллллллллллл" line 9 col 20
display "л л" line 10 col 20
display "л л" line 11 col 20
display "л USER NAME : л" line 12 col 20
display "л л" line 13 col 20
display "л PASSWORD : л" line 14 col 20
display "л л" line 15 col 20
display "л л" line 16 col 20
display "ллллллллллллллллллллллллллллллллллллл" line 17 col 20
move space to user-name
move space to pword
accept user-name line 12 col 36 with empty-check
accept pword line 14 col 36 with no-echo
if user-name is equal to "NITU" and pword is equal to "NS098"
go to createpara
else if user-name is equal to "KUNJAN" and pword is equal to "KM074"
go to createpara
else if user-name is equal to "KADIR" and pword is equal to "KD085"
go to createpara
else if user-name is equal to "HABEEB" and pword is equal to "HB087"
go to createpara
else if user-name is equal to "PIYUSH" and pword is equal to "PY106"
go to createpara
else display "WRONG USER NAME OR PASSWORD" line 5 col 27 with blink
display " TRY ONCE AGAIN !!! " line 16 col 24 with blink
accept ans
end-if
if passcount>3 then
perform exit-para
end-perform.


/*********************** DESIFN FORM *****************************
CREATEPARA.
DISPLAY (1,2) "WELCOME TO OUR PROJECT" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,26) "* * ***** ***** " WITH REVERSE-VIDEO
DISPLAY (9,26) " * * ** * ** * " WITH REVERSE-VIDEO
DISPLAY (10,26)" * * ** * ** * " WITH REVERSE-VIDEO
DISPLAY (11,26)" * * * * " WITH REVERSE-VIDEO
DISPLAY (12,26)" * ***** ****** " WITH REVERSE-VIDEO
DISPLAY (4,27) " PROJECT FOR"
DISPLAY (5,25) " HOSTEL MANAGEMENT SYSTEM "
DISPLAY (6,24) "---------------------------------"
DISPLAY (22,49) "PRESS ANY KEY TO CONTINUE"
ACCEPT ANS
PERFORM MAINPG-PARA.
/***************** MAIN PAGE FORM *******************

MAINPG-PARA.
PERFORM UNTIL MAINREP = "N"
DISPLAY (4,28) "*** MAIN FORM ***" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
DISPLAY (6,23) "1. ADD HOSTEL INFORMATION "
DISPLAY (8,23) "2. NEW STUDENT ENTRY "
DISPLAY (10,23) "3. DELETE STUDENT RECORD "
DISPLAY (12,23) "4. MODIFY STUDENT RECORD "
DISPLAY (14,23) "5. REPORT GENERATION"
DISPLAY (16,23) "6.EXIT"
DISPLAY (20,23) " ENTER YOUR CHOICE := " WITH BLINK
MOVE SPACES TO MCH
ACCEPT MCH
EVALUATE MCH
WHEN 1
PERFORM M1PARA
WHEN 2
PERFORM M2PARA
WHEN 3
PERFORM M3PARA
WHEN 4
PERFORM M4PARA
WHEN 5
PERFORM MAINREPORTPARA
WHEN 6
PERFORM EXIT-PARA
END-EVALUATE
DISPLAY (22,12) "DO YOU WANT TO CONTINUE THE PROJECT...(Y/N).. = "
MOVE SPACES TO MAINREP
ACCEPT MAINREP
IF MAINREP = "N" THEN
PERFORM EXIT-PARA
END-IF
END-PERFORM.
M1PARA.
PERFORM UNTIL M1REP = "N"
PERFORM M1CHPARA

OPEN EXTEND HFILE

PERFORM M1ENTRY2PARA
CLOSE HFILE
DISPLAY (20,12) "DO YOU WANT TO ENTER MORE RECORDS...(Y/N) := "
ACCEPT M1REP
END-PERFORM.

M1CHPARA.
MOVE 1 TO CHECK1
PERFORM UNTIL CHECK1 = 0
DISPLAY (5,25) "****ADD HOSTEL RECORD FORM****" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,12) "ENTER HOSTEL NAME = "
ACCEPT NHNM
DISPLAY (10,12) "ENTER ROOM NUMBER = "
ACCEPT NRNO
MOVE 0 TO FLAG1
PERFORM M1CHECKPARA

IF FLAG1 = 0 THEN
MOVE 0 TO CHECK1
END-IF
END-PERFORM.

M1CHECKPARA.
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (NHNM = HNAME) AND (NRNO = ROOMNO) THEN
DISPLAY (13,15) "THIS ROOM NO. ALREADY EXIST........" WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (17,15) "PLEASE ENTER DIFFERENT CODE"
DISPLAY (20,20) "ENTER ANY KEY TO CONTINUE... "
ACCEPT ANS
MOVE 1 TO FLAG1
MOVE "F" TO CHOICE1
END-IF


END-READ
END-PERFORM
CLOSE HFILE
.
M1ENTRY2PARA.
MOVE NHNM TO HNAME
MOVE NRNO TO ROOMNO
DISPLAY (12,12) "ENTER NUMBER OF BEDS IN THE ROOM = "
ACCEPT TOTALBED
MOVE TOTALBED TO AVAILBED
DISPLAY (14,12) "NEW RECORD ENTERED... "
WRITE INHOSTELREC FROM INHOSTELDETAILS

M2PARA.
PERFORM UNTIL M2REP = "N"
MOVE 0 TO FLAG2
DISPLAY (4,25) "****ADD STUDENT RECORD FORM****" WITH BLANK SCREEN
display (2,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
display (23,1) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

OPEN EXTEND SFILE
OPEN EXTEND OUTF
PERFORM M2ENTRYPARA
CLOSE SFILE
CLOSE OUTF
DISPLAY (20,12) "DO YOU WANT TO ENTER MORE RECORDS...(Y/N) := "
ACCEPT M2REP
END-PERFORM.
M2ENTRYPARA.
DISPLAY(6,12) "ENTER STUDENT NAME: "
ACCEPT SNAME
DISPLAY(8,12) "ENTER REGISTRATION NUMBER: "
ACCEPT REGNO
DISPLAY(10,12) "ENTER COURSE: "
ACCEPT COURSE
DISPLAY (12,12) "ENTER YEAR: "
ACCEPT YEAR
DISPLAY(14,12) "ENTER FEE PAID: "
ACCEPT FPAID
DISPLAY (16,12) "ENTER HOSTEL NAME STUDENT WANT: "
ACCEPT THLNO
PERFORM M2FEECHECKPARA.

M2FEECHECKPARA.
IF FPAID = 55000 THEN
MOVE 1 TO TRT.
IF FPAID = 50000 THEN
MOVE 2 TO TRT.
IF FPAID = 45000 THEN
MOVE 3 TO TRT.
IF FPAID = 40000 THEN
MOVE 4 TO TRT.
IF FPAID = 35000 THEN
MOVE 10 TO TRT.

PERFORM HOSTELAVAILPARA.
HOSTELAVAILPARA.
MOVE 'T' TO CHOICE1
OPEN INPUT HFILE
OPEN OUTPUT TEMPF
PERFORM UNTIL CHOICE1 = "F"
READ HFILE INTO INHOSTELDETAILS
AT END
MOVE "F" TO CHOICE1
NOT AT END
IF (FLAG2 = 0) AND (THLNO = HNAME) AND (TRT = TOTALBED) THEN
IF (AVAILBED > 0) THEN
MOVE 1 TO FLAG2
MOVE ROOMNO TO TRM
COMPUTE AVAILBED = AVAILBED - 1
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
ELSE
WRITE INTEMPREC FROM INHOSTELDETAILS
END-IF
END-READ
END-PERFORM
CLOSE HFILE
CLOSE TEMPF
PERFORM MAINENPARA.
MAINENPARA.
IF FLAG2 = 1 THEN
DISPLAY (14,12) "NEW RECORD ENTERED... " WITH BLANK SCREEN
PERFORM DOCPARA
WRITE INSTUDENTREC FROM INSTUDENTDETAILS
MOVE SNAME TO SNAME-O
MOVE REGNO TO REGNO-O
MOVE COURSE TO COURSE-O
MOVE YEAR TO YEAR-O
MOVE THLNO TO HNAME-O
MOVE TRM TO ROOMNO-O
ACCEPT EDATE FROM DATE
WRITE OUTMAINREC FROM OUTMAINDETAILS
DISPLAY (8,10) "STUDENT HAS GOT ROOM NO: " WITH BLANK SCREEN
PERFORM DOCPARA
DISPLAY (8,38)TRM
DISPLAY (9,10) "IN HOSTEL "
DISPLAY (9,21) THLNO
&nbs
Was This Post Helpful? 0
  • +
  • -

#10 sakthisridhar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 21-December 08

Re: regarding database connectivity in COBOL

Posted 19 January 2009 - 12:15 AM

View Postn8wxs, on 22 Dec, 2008 - 08:56 PM, said:

hai sir,

happy belated new year to you.


I HAVE ONE DOUBT REGARDING DATABASE CONNECTIVITY IN COBOL.PLEASE TELL ME SOON. IT IS VERY URGENT.

Presently in my system i have installed oracle 9i version 9.2 . i have install ed this oracle because i read in some site that oracle 9i has included pro*cobol so can u please tell me how to do this pro*cobol program in windows platform.


i have tried so far but it shows 50 errors . i am presently using cobol 85 compiler i have one program reagarding database i just pasted that in my dos editor by giving the folllowing command:

E:Try> cobol3 sample1.pco
when i pressed enter it show error .

how to compile and execute the pro*cobol program
please write the command so that i can just give that command in my system.



please very urgent sir








THIS IS THE ERROR WHICH I AM GETTING WHEN I COMPILE PRO*COBOL 

E:\oracle\ora92\precomp\demo\procob2>procob sample1.pco

Pro*COBOL: Release 9.2.0.1.0 - Production on Sun Jan 18 23:12:13 2009

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

System default option values taken from: E:\oracle\ora92\precomp\admin\pcbcfg.cf
g


E:\oracle\ora92\precomp\demo\procob2>makeit sample1

E:\oracle\ora92\precomp\demo\procob2>procob iname=sample1.pco ireclen=132

Pro*COBOL: Release 9.2.0.1.0 - Production on Sun Jan 18 23:12:37 2009

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

System default option values taken from: E:\oracle\ora92\precomp\admin\pcbcfg.cf
g


E:\oracle\ora92\precomp\demo\procob2>echo Compiling sample1......
Compiling sample1......

E:\oracle\ora92\precomp\demo\procob2>cobol sample1 /anim /litlink /ibmcomp /NEST
CALL makesyn "COMP-5" = "COMP";
'cobol' is not recognized as an internal or external command,
operable program or batch file.

E:\oracle\ora92\precomp\demo\procob2>cbllink sample1 /Msample1 E:\oracle\ora92/p
recomp\lib\oraSQL9.lib
'cbllink' is not recognized as an internal or external command,
operable program or batch file.

E:\oracle\ora92\precomp\demo\procob2>



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1