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
*
EVALUATE TRUE
WHEN SQLCODE = +000
MOVE WS-COUNT TO Copybook field
WHEN SQLCODE = +100
MOVE ZEROES TO Copybook field

Answer Posted / mahendran

There can be 2 scenarios.

scenario #1

when field1 and field2 are keys on dbfile or keys of LF on
dbfiles

1. Start the DB file with field1 and field2.
2. Read the DB file next record and increase the counter
value.
3. End the process, when end of file reached.
4. if the counter value is greater than zero then move the
counter value to Copybook field else move zeros to the
copybook fields.

scenario #2

when field1 and field2 are not keys on dbfile or not part
of keys of any LF on dbfiles

1.Read the file
2.If the field1 = WS-VAR and Field2 = WS-USERID then
increase the counter
value.
3. End the process, when end of file reached.
4. if the counter value is greater than zero then move the
counter value to Copybook field else move zeros to the
copybook fields.

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how to detect record is locked in cobol/400? What is the solution for that?

531


How to detect record is locked in cobol/400? What is the solution for that?

523


How to detect record is locked in cobol/400?

538


What is input procedure?

578


What is the syntax of sort?

538






Explain the difference between search and searchall?

511


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

646


why icetool be used in programmer view?

2143


Explain the difference between comp & comp-3?

545


What are fillers?

527


What is comp?

549


Explain the input procedure?

535


What is output procedure?

543


Explain what all the conditiones required for using open opcode on a file?

503


Explain the output procedure?

573