midrange.com code scratchpad
Name:
SQL EXECUTE that works in V5R4 but not in V6R1
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
05/05/2010 02:11:04 pm
IP:
Logged
Description:
The user was to lazy to give a description
Code:
  1.  
  2. D wSqlStmt        S            500A   VARYING INZ   
  3.  
  4. D  wSqlDS          DS                   
  5. D  wInstr                        12     
  6. D  wTable                       21     
  7. D  wSetClause               200     
  8. D  wWhereClause           200     
  9.  
  10. // Preprare an SQL update statement from information read from file ( field names have prefix 'U' )
  11. wInstr = gUPDATE ; 
  12.                                                      
  13. wTable = %TRIM (UBIBNM) + '/' + %TRIM (UFICNM) ;                          
  14. wSetClause = gSET + %TRIM(UINFNM) +              
  15.              ' = ?' ;                            
  16.                
  17.    IF UANLNM <> *BLANKS ;                        
  18.       wSetClause = %TRIM(wSetClause) +           
  19.                    ', ' + %TRIM (UANLNM) +       
  20.                    ' = '' ''' ;                  
  21.    ENDIF ; 
  22.                                       
  23.    IF UUSRNM <> *BLANKS ;                        
  24.       wSetClause = %TRIM(wSetClause) +           
  25.                    ', ' + %TRIM (UUSRNM) +       
  26.                    ' = ?' ;                      
  27.    ENDIF ;   
  28.                                     
  29.    IF UMDLNM <> *BLANKS ;                        
  30.       wSetClause = %TRIM(wSetClause) +           
  31.                    ', ' + %TRIM (UMDLNM) +       
  32.                    ' = CURRENT_DATE' ;           
  33.    ENDIF ;   
  34.                                     
  35.    IF UMHTNM <> *BLANKS ;                        
  36.       wSetClause = %TRIM(wSetClause) +           
  37.                    ', ' + %TRIM (UMHTNM) +       
  38.                    ' = CURRENT_TIME' ;           
  39.    ENDIF ;
  40.                                        
  41.                               
  42. wWhereClause = gWHERE + %TRIM(UINFNM) +          
  43.              ' = ?' ;                            
  44.    IF UANLNM <> *BLANKS ;                        
  45.       wWhereClause = %TRIM(wWhereClause) +       
  46.                    ' and ' + %TRIM (UANLNM) +    
  47.                    ' = '' ''' ;                  
  48.    ENDIF ;      
  49.                             
  50.    wSqlStmt = wSqlDS ;                                       
  51.      EXEC SQL                                                  
  52.          PREPARE SqlReq FROM :wSqlStmt ;                        
  53.          
  54. // Update of file ( name read from file )  
  55.          IF UUSRNM = *BLANKS ;                                     
  56.             EXEC SQL                                               
  57.                EXECUTE SqlReq USING :wCltDstNo, :wCltOriNo ;       
  58.                               
  59.                If SQLCOD < 0;                                      
  60.                   //handle erreur                                    
  61.                EndIf;                                              
  62.                                             
  63.          ELSE ;                                                    
  64.             EXEC SQL                                               
  65.                EXECUTE SqlReq USING :wCltDstNo, :gUSER_ID,         
  66.                :wCltOriNo ;                                        
  67.                If SQLCOD < 0;                                      
  68.                   //handle erreur                                    
  69.                EndIf;                                              
  70.  
© 2004-2019 by midrange.com generated in 0.006s valid xhtml & css