× 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.



Two things come to mind.

1.  Have you checked the value of SQLSTT after the declare?  If there is 
something wrong with the declare you will get a non-zero value in SQLSTT.  If 
so, check the value in SQLCOD.  Take the last four numbers and append them to 
SQL.  Display the associated error message using DSPMSGD. For example DSPMSGD 
SQL0180 MSGF(QSQLMSG). 

2.  I don't believe you don't need a cursor for what you are doing.  Try using 
the SELECT INTO statement instead.  The same rules about SQLSTT apply.

Rick

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Douglas W. Palme
Sent: Thursday, July 14, 2005 9:04 AM
To: RPG Group
Subject: sql saga continues


I spent the better portion of the night last night continuing to work with
the embedded sql code.....of course its a learning curve and at times
frustrating as hell but I am learning it slowly....


I have however run into a situation that after 4 hours I have not been able
to figure out.  I have created a very simple sqlrpgle program that for right
now is just to get the count of the records and write it to a variable. 
Sounds simple enough, however when running it in bebug mode it seems to
execute but when I F11 the variable to see its value, its all zeroes.

Here is the pertinent code:

0029.03  ***********************************************************
0039.01  *       STANDALONE VARIABLES                              
0041.00  ***********************************************************
0041.03 DSDATE            S               D   DATFMT(*USA)         
0041.04 DEDATE            S               D   DATFMT(*USA)         
0041.05 DTCOUNT           S              6S 0                      
0041.06  ***********************************************************
0042.00  *       MAINLINE                                          
0043.00  ***********************************************************
0043.01 C     *USA          MOVE      '06/01/2005'  SDATE          
0043.02 C     *USA          MOVE      '06/30/2005'  EDATE          
0043.03 C                   EXSR      COUNTING                     
0043.29 C                   EVAL      *INLR = *ON                  
0043.30 C                   RETURN                                 
0043.31  ***********************************************************
0044.00  *       GET RECORD COUNT AND WRITE TOTAL TO TCOUNT VARIABLE
0045.00 C     COUNTING      BEGSR      
0046.00 C/EXEC SQL                     
0047.00 C+    DECLARE COUNTCURSOR CURSOR
0048.00 C+    FOR SELECT COUNT(*) FROM 
0049.00 C+    INVMARGIN WHERE          
0050.00 C+    ILNINVDATE >= :SDATE AND 
0051.00 C+    ILNINVDATE <= :EDATE     
0052.00 C/END-EXEC                     
0053.00 C/EXEC SQL 
0054.00 C+ FETCH COUNTCURSOR    
0055.00 C+ INTO :TCOUNT         
0056.00 C/END-EXEC                                  
0057.00 C                   ENDSR
0058.00  ************************

I did not see any problem with the cursor or the fetch statement, and since
the variable tcount is declared it should work....I also noticed when I F11
on the :tcount it says that it cannot find the variable...which I thought
was strange but maybe its my brain having one of its moments.

Any helpful suggestions would be appreciated.



Privileged and Confidential.  This e-mail, and any attachments there to, is 
intended only for use by the addressee(s) named herein and may contain 
privileged or confidential information.  If you have received this e-mail in 
error, please notify me immediately by a return e-mail and delete this e-mail.  
You are hereby notified that any dissemination, distribution or copying of this 
e-mail and/or any attachments thereto, is strictly prohibited.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.