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


  • Subject: AW: Another order by question ?
  • From: "Dusold, Manfred" <M.Dusold@xxxxxxxxxxx>
  • Date: Tue, 3 Jul 2001 13:04:52 +0200

hi Heba,
 
use the "ifnull" - Function to avoid undefined value.
 
 
C/EXEC SQL                                                        
   C+   DECLARE @CURSOR1 CURSOR FOR                                  
   C+   SELECT  file1.flda , file1.fldb , file1.fldc, ifnull( file2.seqno, 0 ) dummy                    
   C+   FROM file1 LEFT JOIN file2                              
   C+   ON file1.fldb  = file2.fldb                        
   C+   AND file1.fldc = file2.fldc                        
   C+   ORDER BY dummy
   C/EXEC SQL          
Manfred
 
 
 
 -----Ursprüngliche Nachricht-----
Von: Refaie.Heba@khb.hu [mailto:Refaie.Heba@khb.hu]
Gesendet: Dienstag, 26. Juni 2001 11:59
An: RPG400-L@midrange.com
Betreff: Another order by question ?


Hi Group,

      I have a SQLRPGLE program which runs this SQL statement

   C/EXEC SQL                                                        
   C+   DECLARE @CURSOR1 CURSOR FOR                                  
   C+   SELECT  file1.flda , file1.fldb , file1.fldc, file2.seqno                    
   C+   FROM file1 LEFT JOIN file2                              
   C+   ON file1.fldb  = file2.fldb                        
   C+   AND file1.fldc = file2.fldc                        
   C+   ORDER BY file2.seqno
   C/EXEC SQL          


Obviously, I want to simulate the selection of the matched records with the primary file (like a query join option 2). I made this join just because I want to process ALL the records in file1 according to the seqno in file2 which is a (normal numeric field). those records in file A that don't have corresopndance in file B I want to process them at the end (in the normal sort sequence).  

It works fine until it comes to a record from the primary file that does not have a correspondence on the right side, in this case the fetch returns -305 sqlcod (Indicator variable required). I think this is because the host variable to store the seqno which is also a normal numeric variable, can not handle the undefined value coming from the join. It is not important to me to include the file2.seqno in the select. I did so just to be able to use the order by clause. How can I overcome this?


Thanks in advance
Heba

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.