How can i change the below code in SQL to cobol/400?
EXEC SQL SELECT COUNT(*) INTO : WS-COUNT FROM Db file
WHERE Field 1 = : WS-VAR AND
Field 2 = : WS-USERID
END-EXEC

Answer Posted / srinivas

Declare below three variables in working storage section.

77 WS-COUNT PIC 99. VALUE ZEROS.
77 WS-VAR PIC X(10) VALUE "WELCOME".
77 WS-USERID PIC x(5) VALUE "AAAAA".
Decalre one indicator for end of file.
04 EOF-DB-FILE PIC X VALUE "N".
88 EOF-DB-FILE VALUE "Y".
Read each record from input file(Db file) and increase
count if the conditions are satisfied.
PROCEDURE DIVISION.
OPEN INPUT DB-FILE.
READ Db-file
AT END MOVE "Y" TO EOF-DB-FILE
GO TO 1000-EXIT.
IF FIELD1 = WS-VAR AND FIELD2 = WS-USERID
ADD 1 TO WS-COUNT
END-IF
GO TO 1000-EXIT.
DISPLAY WS-COUNT
CLOSE DB-FILE.
STOP RUN.

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to detect record is locked in cobol/400?

538


I like to know if possible to use %TRIM or any statement with prefiv "%" like RPG ile programs. thanks

2064


What is input procedure?

578


What is the syntax of redefine?

535


How to update data area in cobol 400 program?

579






What is the syntax of sort?

540


What is output procedure?

543


Explain how to convert 2010/02/11 to m/dd/yyy.. With string and without string if any other method... Code?

646


Explain the input procedure and output procedure?

521


What are the types of perform?

571


why icetool be used in programmer view?

2143


What is sort?

532


What is perform?

537


What is the actual use of fillers?

503


Define sort?

581