ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

ERROR -206 on PREPARE...sometimes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ERROR -206 on PREPARE...sometimes

    Forgive me if I don't say this quite right.

    I have a stored procedure that "calls" an RPGLE program in which a dynamic SQL statement is used. When I run and debug from the Iseries (calling the RPGLE program directly), everything works great. However, when I ran a debug while my coworker was running his VB code (from Access), it clearly showed a -206 error on the PREPARE. My local guru isn't sure why. We tried a simple recompile and remigrate (we use Rocket Aldon LMI) and that didn't help.

    Now, on Monday we're going to sit down together (me, the coworker and the guru) and see what we can see, but I was wondering if anyone had any ideas

    Here is my code for the PROCEDURE:

    PHP Code:
    CREATE OR REPLACE PROCEDURE &LIB/LBLFLPPR (IN INLOC   CHAR (06),     
                                   
    IN INTYPE  CHAR (01),                 
                                   
    IN INDATE  NUMERIC (70),            
                                   
    IN INTRKGRP NUMERIC (2,0),            
                                   
    IN INFLENO  NUMERIC (2,0),            
                                   
    OUT OUTMSG    CHAR (30))              


    LANGUAGE RPGLE SPECIFIC &LIB/LBLFLPPR NOT                            
    DETERMINISTIC MODIFIES SQL DATA                                      
    CALLED ON NULL                                                       
    INPUT EXTERNAL NAME 
    &LIB/LBLFLGPR                                    
    PARAMETER STYLE GENERAL                                              
    *=========================================================== 
    Here is part of my code for the RPGLE (please ignore my "newbie notes"). %Trim(SQLString) holds 'SELECT * FROM <filename> ' because <filename> changes and is set up immediately before this code.

    PHP Code:
       //a field holds the SQL statement (don't use colons on the          
       //variables, WKTICK is used to put tick marks around characters     
        
    SQLString = %Trim(SQLString) + ' WHERE SADPPRILOC = ' +            
                  
    WKTICK  INLOC  +  WKTICK  +                            
                  
    ' AND  SADRECTYPE = ' +                                  
                  
    WKTICK  +  INTYPE   WKTICK  +                          
                  
    ' AND  SADLDATE = ' +   %CHAR(INLOADDTE)  +              
                  
    ' AND  SADFTRKGP = ' +  %CHAR(INTRKGRP) ;                

        
    //Prepare Statement -this "creates" SQLSTM which is                
        // the SQL statement written into SQLSTRING                        
        
    EXEC SQL                                                           
          Prepare SQLSTM from 
    :SQLSTRING;                                  

        IF 
    SQLCOD <> ;                                                   
          
    LOOPEND 'Y';                                                   
        ENDIF;                                                             

        
    // DECLARE CURSOR - have to do this with a SELECT anytime          
        // you are doing dynamic SQL 
    My code goes on to do a FETCH and then an UPDATE (after a second setup and PREPARE so I UPDATE the right file).

    Thank you for any assistance. Have a good weekend.


  • #2
    I *think* a -206 means "Column &1 not in specified tables." Maybe the VB connection is using a different *LIBL and picking up an old object.

    Ringer

    Comment


    • #3
      Yes, that's what it means. I did check my code for that . I didn't think about his library list, though. I'll double check that part. Thank you.

      Comment

      Working...
      X