New Ranks & Badges For The Community!
Notice something different? The ranks and associated badges have gone "Star Fleet". See what they all mean HERE
Highlighted
Absent Member.
Absent Member.
984 views

Can't access data when selecting records using embedded SQL in COBOL code

 I am adding the following SQL to my COBOL program.  It returns ZEROES as the SQLCODE, but does not put the fields in my COBOL fields so that I can use them in my program.  

 

EXEC SQL
SELECT TOP 1
"CourtEventNo"
,"CrtCaseDefNo"
,"EventDate"
,"EventTime"
,"FineAmount"
,"DeleteInd"
FROM "CR_DefFineCase"
INTO
:J0901-CourtEventNo
,:J0901-CrtCaseDefNo
,:J0901-EventDate
,:J0901-EventTime
,:J0901-FineAmount
,:J0901-DeleteInd
WHERE "CrtCaseDefNo" = :WS-CRTCASE AND
"DeleteInd" = 'N'
ORDER BY
"EventDate" DESC
,"EventTime" DESC
,"CR_DefFineCaseSID" DESC
END-EXEC.

Our configuration

Studio Enterprise Edition 6.0    Platform Net Express       Database is MS SQLServer

 

We have 37 new tables for this project.  Can access tables by primary keys (SIDS), but all access using Alternate keys has been problematic.  This is the code from the first table which I have tried using both the middle tier software to access and embedded SQL.  Both return a SQLCODE value of zero, but no values in the fields declared in the INTO variables.  The second table I tried to access using embedded SQL with a cursor.  It works until it gets to the FETCH statement and then it bombs with a nonsensical error.

0 Likes
2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

What version of SQL Server are you running and what is the name and the version number of the ODBC driver that you are using?
0 Likes
Highlighted
Absent Member.
Absent Member.

SQL Server is 2008 R2 Service Pack 2.   ODBC is ODBC Driver 13 for SQL Server Version 2015.130.1601.05  Microsoft Corp  File MSODBCSQL13

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.