Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RPG Embedded SQL

Status
Not open for further replies.

Sandy2009

Programmer
Dec 3, 2008
2
US
Hi, I have a very simple embedded SQL fetch which is not working.... I don't see why. It always returns SQLCode = 100. Help?? I have cut and paste the relevant parts in preformed order......

First step declare:
C*
C/Exec SQL
C+ Declare DRVCursor Scroll Cursor
C+ For Select *
C+ From DVDAYO4
C+ Where DVODRV = :KEYDRV AND
C+ ((DVOFDT >= :CMPFDT AND :CMPFDT <= DVOTDT) OR
C+ (DVOFDT >= :CMPTDT AND :CMPTDT <= DVOTDT) OR
C+ :)CMPFDT <= DVOFDT AND :CMPTDT >= DVOTDT))
C+ For Read Only
C/End-Exec
*

Second Close/Open. (I always close prior to an open...habit)
*
C/Exec SQL
C+ CLOSE DRVCursor
C/End-Exec
*
C/Exec SQL
C+ OPEN DRVCursor
C/End-Exec
*
Lastly - Fetch:
C*
C/Exec SQL
C+ Fetch Next
C+ From DRVCursor
C+ Into :SF1REC
C/End-Exec
*

Data Structure SF1REC:

DSF1REC DS
D INDRV 4S 0
D INFDT 8S 0
D INFTM 4S 0
D INTDT 8S 0
D INTTM 4S 0
D INRSN 1A
D INDES 35A
D INACT 1A
D INSEQ 5S 0
D* INDEL 1A


File Layout:
*
A R DVDAYOP PFILE(DVDAYO)
A DVODRV 4S 0 TEXT('DRIVER NUMBER')
A DVOFDT 8S 0 TEXT('FROM DATE')
A DVOFTM 4S 0 TEXT('FROM TIME')
A DVOTDT 8S 0 TEXT('TO DATE')
A DVOTTM 4S 0 TEXT('TO TIME')
A DVORSN 1A TEXT('REASON CODE')
A DVODES 35A TEXT('REASON DESCRIPTION')
A DVOACT 1A TEXT('ACTION CODE')
A DVOSEQ 5S 0 TEXT('SEQUENCE NUMBER')
A DVODEL 1A TEXT('DELETED')
A K DVODRV
A K DVOFDT
A K DVOFTM
A K DVOTDT
A K DVOTTM
A S DVODEL COMP(NE 'D')
A*

Then Close Cursor on Exit

Thank You in Advance!
 
I found the problem....... just had to walk away for a minute.
 
pls read what Birgitta Hauser the resident guru of all things SQL notifies on this.

"Never specify a DDS described logical file in an SQL statement, because the query will be rewritten based on the underlying physical file by the optimizer before the optimization process begins. Additionally only the CQE optimizer can handle DDS described logical files".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top