|
This is a multipart message in MIME format.
--
[ Picked text/plain from multipart/alternative ]
When I do an "order by" I do not get consistent results with imbedded SQL
(CRTRPGSQLI). Yet it works with STRSQL
For example when I do the following with STRSQL it sorts by the specified
column number:
SELECT CMID, CCUST, CNME
FROM DHTDIVF/RCM
ORDER BY 3
But the following program seems to pick a different first row upon every
execution:
/DEFINE HSpec
/INCLUDE ROUTINES/QRPGLESRC,HSPEC
/UNDEFINE HSpec
***************************************************************************
* Program: *
* *
* *
* Modification log: *
* mm/dd/02 by R.Berendt, CCP Group Dekko Services, LLC *
* Created. *
* *
* Compilation instructions: *
* (no special instructions this time.) *
* *
***************************************************************************
/DEFINE DSpec
D DARREN2 PR EXTPGM('DARREN2')
D Parm1 like(OrderBy)
/INCLUDE ROUTINES/QRPGLESRC,SRVPGMCPY
D DARREN2 PI *ENTRY PLIST
D Parm1 like(OrderBy)
D OrderBy s 3p 0
D NewOrderBy s 5i 0
D SqlStmt s 32000a varying
D rcm e ds extname(rcm)
/UNDEFINE DSpec
C/EXEC SQL
C+ Set Option Commit = *none
C/END-EXEC
/free
SqlStmt='Select ccust, cnme, cad1, cad2, cste, czip ' +
'From rcm ' +
'Order by ?';
NewOrderBy = Parm1;
/end-free
C/EXEC SQL
C+ Prepare SqlStmt from :SqlStmt
C/END-EXEC
/free
eval Sqlstt=Sqlstt; // debug
/end-free
C/EXEC SQL
C+ Declare CustomerCursor Cursor
C+ For SqlStmt
C/END-EXEC
/free
eval Sqlstt=Sqlstt; // debug
/end-free
C/EXEC SQL
C+ Open CustomerCursor using :NewOrderBy
C/END-EXEC
/free
eval Sqlstt=Sqlstt; // debug
/end-free
C/EXEC SQL
C+ Fetch Next
C+ From CustomerCursor
C+ Into :ccust, :cnme, :cad1, :cad2, :cste, :czip
C/END-EXEC
/free
eval Sqlstt=Sqlstt; // debug
/end-free
C/EXEC SQL
C+ Close CustomerCursor
C/END-EXEC
/free
eval Sqlstt=Sqlstt; // debug
*inlr=*on;
return;
/end-free
Rob Berendt
--
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety."
Benjamin Franklin
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.