Topic
  • 5 replies
  • Latest Post - ‏2014-06-27T06:08:14Z by tomliotta
msoucy
msoucy
61 Posts

Pinned topic Parameters in RPG ILE service program

‏2014-06-25T19:07:39Z |

I have a question about defining parameters in an RPG ILE service program.  I have an RPG ILE service program that I've written.  The service program is called via a SQL Stored procedure.  The stored procedure passes three parameters.  I want to add a forth parameter to be returned back to the stored procedure so I know that my RPG logic was successful in what it is doing.  When I define the parameter in my SQL stored procedure I give it a parameter type of INOUT.  When I call my stored procedure I get an error saying "IN, OUT, or INOUT not valid for parameter 4 in procedure MHMASTO_IN".  It doesn't seem to like that I defined it as an INOUT parameter.  Is there something special I need to do in my RPG ILE service program when I define the parameter?

  • scott_klement
    scott_klement
    260 Posts

    Re: Parameters in RPG ILE service program

    ‏2014-06-26T01:47:47Z  

    Can you please post the RPG prototype and the Create Procedure statement that you're using?

    I don't think SQL looks at your RPG code at all, so if you're getting an error about INOUT not being allowed, I don't think this relates to anything inside the RPG code itself.  Instead, I'd suggest that the error is within your Create Procedure statement.

     

  • msoucy
    msoucy
    61 Posts

    Re: Parameters in RPG ILE service program

    ‏2014-06-26T12:59:09Z  

    Can you please post the RPG prototype and the Create Procedure statement that you're using?

    I don't think SQL looks at your RPG code at all, so if you're getting an error about INOUT not being allowed, I don't think this relates to anything inside the RPG code itself.  Instead, I'd suggest that the error is within your Create Procedure statement.

     

    Hi Scott,

    Thank you for your reply.  Attached are my procedure prototype and the source for my create procedure.

    Mike

    Attachments

    Updated on 2014-06-26T13:19:24Z at 2014-06-26T13:19:24Z by msoucy
  • scott_klement
    scott_klement
    260 Posts

    Re: Parameters in RPG ILE service program

    ‏2014-06-26T15:22:05Z  

    The 'external name' you've specified is missing the library, which results in an error when I try to run the CREATE PROCEDURE.   When I fix that, however, it will create without any errors.   I don't have any problem with the INOUT part (though I didn't actually run it, just did the CREATE PROCEDURE.)

    Do you get the error during the CREATE, or does it happen at run time?

     

  • msoucy
    msoucy
    61 Posts

    Re: Parameters in RPG ILE service program

    ‏2014-06-26T15:40:58Z  

    The 'external name' you've specified is missing the library, which results in an error when I try to run the CREATE PROCEDURE.   When I fix that, however, it will create without any errors.   I don't have any problem with the INOUT part (though I didn't actually run it, just did the CREATE PROCEDURE.)

    Do you get the error during the CREATE, or does it happen at run time?

     

    Hi Scott,

    I should state the reason why I didn't qualify the external name with a library is because I'm using a change management system to manage my IBM I objects and they don't require a library name.  The procedure creates fine.  I get the error I stated above when I attempt to call the SQL stored procedure.  If I change the type to "IN" it works.  For some strange reason it doesn't like INOUT or OUT when I try to call the stored procedure.  If RPG is unable to return a value back to the stored procedure then maybe I can find another way to do this.  I have some iSeries SQL books, but they are really old (publish dates in 2001 and 2004).  I can't find an example of a SQL stored procedure returning a parameter when calling a RPG ILE service program.

    Thank you!

  • tomliotta
    tomliotta
    27 Posts

    Re: Parameters in RPG ILE service program

    ‏2014-06-27T06:08:14Z  
    • msoucy
    • ‏2014-06-26T15:40:58Z

    Hi Scott,

    I should state the reason why I didn't qualify the external name with a library is because I'm using a change management system to manage my IBM I objects and they don't require a library name.  The procedure creates fine.  I get the error I stated above when I attempt to call the SQL stored procedure.  If I change the type to "IN" it works.  For some strange reason it doesn't like INOUT or OUT when I try to call the stored procedure.  If RPG is unable to return a value back to the stored procedure then maybe I can find another way to do this.  I have some iSeries SQL books, but they are really old (publish dates in 2001 and 2004).  I can't find an example of a SQL stored procedure returning a parameter when calling a RPG ILE service program.

    Thank you!

    The service program is called via a SQL Stored procedure.

    Please clarify this. Do you have a SQL stored procedure that has a CALL to your ILE RPG stored procedure? Or are you only referring to your ILE RPG stored procedure as a "SQL stored procedure". There are two types of stored procedures, SQL and 'external'. If one is written in ILE RPG, it is an 'external' stored procedure and not a SQL stored procedure.

    Wild guesswork follows -- The main reason I'm asking is because there are different ways to CALL stored procedures. One type of CALL is known as 'dynamic'. A 'dynamic' CALL to an external stored procedure can only have IN parameters.

    That doesn't seem to fit with your case because you're apparently making the CALL to a service program, and I haven't seen a way to make a 'dynamic' stored procedure CALL to a service program procedure. But it's certainly odd that the error comes down to the INOUT parameter.

    Please show us how you CALL the stored procedure. Maybe there is something odd about that. and the error that you see is not exactly what is really happening.

    Tom