SQL Error when running JumpStart generated code for expanding SubFile

Use this board to ask questions or have discussions with other JumpStart users.
mdruk1986
New User
Posts: 12
Joined: Fri Jan 08, 2016 5:54 pm
First Name: michael
Last Name: RICHARD
Company Name: sylacauga utilities board
Phone: 256 401 2501
State / Province: Alabama
Country: United States
Contact:

SQL Error when running JumpStart generated code for expanding SubFile

Post by mdruk1986 »

Hello,
I used JumpStart to generate a page at a time SubFile with a search field. The Subfile loads and displays correctly. However, when i enter a search term it throws a SQL System error which i have attached. However, when i manually code in the search term or use a variable instead of parameter marker it works. Please see rpg code below. Pretty sure the problem is how i am handling the "SearchTerm" variable but do not see how to fix it.

Any Ideas?

RPG CODE
****************************************************                                                                          
      ** Procedure: Open_SQL                            **                                                                          
      ** Procedure Prepare, Declare and Open SQL cursor **                                                                          
      **   Parms:                                       **                                                                          
      **     None                                       **                                                                          
      **   Return:                                      **                                                                          
      **     None                                       **                                                                          
      ****************************************************                                                                          
     P Open_SQL        B                                                                                                            
     D Open_SQL        PI              N                                                                                            
     D PrevSortField...                                                                                                             
     D                                     like(Ctl_Fields.Sortfield)                                                               
                                                                                                                                    
     D Statement       S           4096A   varying                                                                                  
     D SearchTerm      S             23A   varying                                                                                  
                                                                                                                                    
      /Free                                                                                                                         
                                                                                                                                    
         EXEC SQL                                                                                                                   
           Set Option                                                                                                               
             Naming = *Sys,                                                                                                         
             Commit = *None,                                                                                                        
             UsrPrf = *User,                                                                                                        
             DynUsrPrf = *User,                                                                                                     
             Datfmt = *iso,                                                                                                         
             CloSqlCsr = *EndMod ;                                                                                                  
                                                                                                                                    
       // Original jumpstart generated command immediately below                                                                    
       //SearchTerm = '%' + %Trim(Ctl_Fields.Search) + '%' ;                                                                        
         SearchTerm = '''' + %Trim(Ctl_Fields.Search) + '%''' ;                                                                     
         Statement = 'SELECT * FROM UBAMF ' ;                                                                                       
         If CTL_Fields.Search <> *Blanks ;                                                                                          
           Statement += 'WHERE UNAME LIKE ? ' ;                                                                                     
       //  Statement += 'WHERE UNAME LIKE' + SearchTerm + ' ' ; this works                                                          
       //  Statement += 'WHERE UNAME LIKE ''SMITH%'' ';         this works                                                          
         EndIf;                                                                                                                     
                                                                                                                                    
         Statement += Order_By(PrevSortField);                                                                                      
                                                                                                                                    
           Statement += ' FOR FETCH ONLY';                                                                                          
                                                                                                                                    
         EXEC SQL                                                                                                                   
           PREPARE S1 FROM :Statement ;                                                                                             
          If SQLCODE < 0;                                                                                                           
            Return *Off;                                                                                                            
          EndIf;                                                                                                                    
                                                                                                                                    
                                                                                                                                    
         EXEC SQL                                                                                                                   
           DECLARE C1 SCROLL CURSOR FOR S1 ;                                                                                        
                                                                                                                                    
          If SQLCODE < 0;                                                                                                           
            Return *Off;                                                                                                            
          EndIf;                                                                                                                    
                                                                                                                                    
         EXEC SQL                                                                                                                   
        // OPEN C1 ;                                                                                                                
             OPEN C1 USING :SearchTerm ;                                                                                            
                                                                                                                                    
        //     :SearchTerm                                                                                                          
        //     ;                                                                                                                    
                                                                                                                                    
          If SQLCODE < 0;                                                                                                           
            Return *Off;                                                                                                            
          EndIf;                                                                                                                    
                                                                                                                                    
         Db_rrn = 1;                                                                                                                
         Ctl_Fields.EnableUp=*Off;                                                                                                  
         Ctl_Fields.EnableDown=*On;                                                                                                 
         Ctl_Fields.PageNo = 1;                                                                                                     
                                                                                                                                    
         return *on;                                                                                                                
                                                                                                                                    
                                                                                                                                    
      /End-Free                                                                                                                     
     P                 E
Attachments
jumpstarterror.jpg
jumpstarterror.jpg (282.13 KiB) Viewed 14062 times
User avatar
Glenn
Profound Logic Staff Member
Posts: 124
Joined: Mon Apr 14, 2014 4:08 pm
First Name: Glenn
Last Name: Hopwood
Company Name: Profound Logic Software
State / Province: Ohio
Country: United States
Contact:

Re: SQL Error when running JumpStart generated code for expanding SubFile

Post by Glenn »

We have reproduced the issue and are working on a solution.

Glenn
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests