× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Ding, Ding, Ding,Ding! That did it.

I am wondering if I were to make the null indicator array like Charles mentioned if that would fix it also. That's maybe what was messing it up in the first place.

Thanks everyone for their responses,
Aaron Bartell
http://mowyourlawn.com


Bryce Martin wrote:
Hey Aaron,

I would try wrapping your OA.HTEORDNBR in a coelesce and setting it to some default value, probably 0 since rpg doesn't like Nulls too much.

coalesce(OA.HTEORDNBR,0) as OA.HTEORDNBR

see if that clears anything up. I'm not sure where else to start with this.... everything looks pretty good unless I'm missing something as well.


Thanks
Bryce Martin
Programmer/Analyst I
Ext. 4777



Aaron Bartell <aaronbartell@xxxxxxxxx> Sent by: rpg400-l-bounces@xxxxxxxxxxxx
11/19/2008 02:32 PM
Please respond to
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>


To
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
cc

Subject
Interesting SQL resultset issue






Hi all,

I don't do a lot of embedded SQL compared to native access so forgive me
if this is a dumb mistake. I have a very simple SQL SELECT statement that
joins two files together (see code at bottom post). My primary table is
OMILOG and OMILOGOA is being joined to it.

When the SQL is run and a record is found in both tables, then everything
works fine and I get the expected results. When there isn't a JOIN match
in OIMLOGOA then everything still works *except* the O.CRTDT contains the
timestamp from the last previous successful JOIN in the result set. This
seems odd because all the other O. subfields are being populated just fine
with table information from OMILOG.

Any ideas?

(BTW, I trimmed down the program to just necessary parts, so if a
definition is missing you know why)

Aaron Bartell
http://mowyourlawn.com

H dftactgrp(*no) ALWNULL(*INPUTONLY)

/copy rxs,RXSCp

D NL s 3I 0

D gSQLRslt ds qualified inz
D hteOrdNbr 9a
D pid 15p 0
D uid 15p 0
D crtDt z
D pgmNam 30a
D svrty 10 0
D txt 256a
/free

*inlr = *on;

out('<table>' +
'<th>HTE Order<br/>Number</th>' +
'<th>Parent<br/>Id</th>' +
'<th>Unique<br/>Id</th>' +
'<th>Created</th>' +
'<th>Program<br/>Name</th>' +
'<th>Svrty</th>' +
'<th>Text</th>'
);
/end-free
C/EXEC SQL
C+ DECLARE omiLogCsr CURSOR FOR
C+ SELECT OA.HTEORDNBR,O.PID,O.UID,O.CRTDT,O.PGMNAM,O.SVRTY,O.TXT
C+ FROM omilog as O
C+ LEFT JOIN OMILOGOA as OA on OA.PID = O.PID
C+ ORDER BY o.pid DESC, o.uid DESC
C/END-EXEC
C/EXEC SQL
C+ OPEN omiLogCsr
C/END-EXEC

C DoU %Subst(SQLStt:1:2) = '02'

C/EXEC SQL
C+ FETCH NEXT FROM omiLogCsr INTO :gSQLRslt :NL
C/END-EXEC
/free

if %subst(SQLStt:1:2) = '00';

out('<tr>' +
'<td>' + gSQLRslt.hteOrdNbr + '</td>' +
'<td>' + %char(gSQLRslt.pid) + '</td>' +
'<td>' + %char(gSQLRslt.uid) + '</td>' +
'<td>' + %char(gSQLRslt.crtdt) + '</td>' +
'<td>' + gSQLRslt.pgmnam + '</td>' +
'<td>' + %char(gSQLRslt.svrty) + '</td>' +
'<td>' + %trim(gSQLRslt.txt) + '</td>' +
'</tr>'
);
else;
leave;
endif;

enddo;

out('</table>');

/end-free
C/EXEC SQL
C+ CLOSE omiLogCsr
C/END-EXEC
/free


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.