Announcement Announcement Module
Collapse
No announcement yet.
Basic stored proc outbound gateway question Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Basic stored proc outbound gateway question

    How do I call a stored procedure with more than one input parameter?

    I'm looking at the Stored Procedures MS sample:
    https://github.com/SpringSource/spri...-procedures-ms

    What I've done is modify the stored proc to take two varchar arguments rather than one, and I've also altered the StringConversionService.convertToUpperCase method signature to take two string arguments, e.g.:
    Code:
    /**
    * Converts a String to Upper Case.
    *
    * @param firstName First name
    * @param lastName Last name
    * @return The converted upper case string (firstName lastName)
    */
    String convertToUpperCase(String firstName, String lastName);
    What I can't figure out is how to set up my int-jdbc:stored-proc-outbound-gateway configuration so that Spring knows how to map the method arguments to the stored procedure parameters.
    Code:
    <int-jdbc:stored-proc-outbound-gateway
        id="outbound-gateway-procedure" request-channel="procedureRequestChannel"
        data-source="dataSource" stored-procedure-name="CAPITALIZE_STRING"
        expect-single-result="true">
        <int-jdbc:parameter name="pfirstName" expression="[WHAT DO I PUT HERE?]" />		
        <int-jdbc:parameter name="plastName" expression="[WHAT DO I PUT HERE?]" />
    </int-jdbc:stored-proc-outbound-gateway>
    Nasty hack of the example's stored procedure, just in case it is relevant:
    Code:
    ALTER PROCEDURE [dbo].[CAPITALIZE_STRING]
        @pfirstName VARCHAR(50),
        @plastName VARCHAR(50) OUTPUT
    		
        AS
        BEGIN
            -- SET NOCOUNT ON added to prevent extra result sets from
            -- interfering with SELECT statements.
            SET NOCOUNT ON;
            select @plastName = upper(@pfirstName + ' ' + @plastName);
        END
    GO
    Best wishes,
    Ben

  • #2
    A message can only have one payload; there are a several options, including...

    Code:
    String convertToUpperCase(@Header("firstName") String firstName, String lastName);
    
    and
    
    <int-jdbc:parameter name="pfirstName" expression="headers.firstName" />		
    <int-jdbc:parameter name="plastName" expression="payload" />
    or make a simple bean

    Code:
    String convertToUpperCase(NameBean name);
    
    and
    
    <int-jdbc:parameter name="pfirstName" expression="payload.firstName" />		
    <int-jdbc:parameter name="plastName" expression="payload.lastName" />
    Where NameBean is a simple bean using JavaBean conventions (getFirstName(), getLastName()).

    Comment


    • #3
      Thanks

      Originally posted by Gary Russell View Post
      A message can only have one payload; there are a several options, including...
      Thank you for your prompt reply Gary, that is exactly what I needed to know, and it works perfectly.

      Best wishes,

      Ben

      Comment

      Working...
      X