ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Sqlcode +326

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

  • #16
    Re: Sqlcode +326

    Here's before the change (getting 326):

    Code:
     * SQL Data Structures                                   
    d echds           e ds                  extname(ech)       
    d eclds            e ds                  extname(ecl)       
    d w7zp1          e ds                  extname(zp1)       
    d a63007fads  e ds                  extname(a63007fa)  
    
    c/exec sql                                                     
    c+ declare a63007facursor cursor for select * from a63007fa    
    c+ where s1user = :wsuser and (s1prt = ' ' or s1prt = :pxeprt) 
    c+ and s1effdt between :pxefdte and :pxetdte                   
                                                                   
    c/end-exec                                                     
                                                                   
    c/exec sql                                                     
    c+ open a63007facursor                                         
    c/end-exec                                                     
     * if cursor is already open, close it and re-open it          
    c                   If        sqlcod = -502                    
    c/exec sql                
    c+ close a63007facursor                 
    c/end-exec                              
    c/exec sql                              
    c+ open a63007facursor                  
    c/end-exec                              
    c                   endif               
                                            
    c/exec sql                              
    c+ fetch a63007facursor into :a63007fads
                                                   
    c                   dow       sqlcod = *zero
    MADE THIS CHANGE (moved the DS to the top) and program functions correctly, w/o +326 SQLCODE. Go Figure:


    Code:
     * SQL Data Structures                                   
    d a63007fads  e ds                  extname(a63007fa)  
    d echds           e ds                  extname(ech)       
    d eclds            e ds                  extname(ecl)       
    d w7zp1          e ds                  extname(zp1)       
    
    
    c/exec sql                                                     
    c+ declare a63007facursor cursor for select * from a63007fa    
    c+ where s1user = :wsuser and (s1prt = ' ' or s1prt = :pxeprt) 
    c+ and s1effdt between :pxefdte and :pxetdte                   
                                                                   
    c/end-exec                                                     
                                                                   
    c/exec sql                                                     
    c+ open a63007facursor                                         
    c/end-exec                                                     
     * if cursor is already open, close it and re-open it          
    c                   If        sqlcod = -502                    
    c/exec sql                
    c+ close a63007facursor                 
    c/end-exec                              
    c/exec sql                              
    c+ open a63007facursor                  
    c/end-exec                              
    c                   endif               
                                            
    c/exec sql                              
    c+ fetch a63007facursor into :a63007fads
                                                   
    c                   dow       sqlcod = *zero
    Last edited by FaStOnE; December 2, 2009, 07:31 AM. Reason: What ever happened to people using the CODE key?

    Comment


    • #17
      Re: Sqlcode +326

      Check your D specs again, please.

      Since it worked by moving its position, it probably means a field was defined AFTER your DS without the "S". That made the field a part of your DS.

      Now, you've moved it and the "SQL" is working but is your program working correctly? That field is probably a part of the last defined DS now.
      â??No bird soars too high if he soars with his own wingsâ?? â?? William Blake

      Comment


      • #18
        Re: Sqlcode +326

        I'm agree with kausix777 !
        Moving the DS resolve the problem, No, it's impossible !
        you have another problem.
        Patrick

        Comment


        • #19
          Re: Sqlcode +326

          Originally posted by kausix777 View Post
          Check your D specs again, please.

          Since it worked by moving its position, it probably means a field was defined AFTER your DS without the "S". That made the field a part of your DS.

          Now, you've moved it and the "SQL" is working but is your program working correctly? That field is probably a part of the last defined DS now.
          if you're correct (i suspect you are) then yes the w7zp1 DS will now not be defined as you thought and will have the additional field added to the end of that DS.
          I'm not anti-social, I just don't like people -Tommy Holden

          Comment


          • #20
            Re: Sqlcode +326

            How to include source code in your post.
            "Time passes, but sometimes it beats the <crap> out of you as it goes."

            Comment

            Working...
            X