Results 1 to 3 of 3

Thread: Basic stored proc outbound gateway question

  1. #1
    Join Date
    Feb 2013
    Posts
    6

    Default 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. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,020

    Default

    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()).
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    Feb 2013
    Posts
    6

    Default Thanks

    Quote 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •