IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
Expand all | Collapse all

Dynamic SQL

  • 1.  Dynamic SQL

    Posted Mon October 13, 2014 08:46 AM

    Hello Team,

    I’m getting below error while trying to execute a dynamic sql function :

    Context :

    1. Created a dynamic SQL adapter service. (Which requires 2 parameters at run time.)

    2. Through a flow service, trying to invoke above adapter - Resulting in Error :

      "(S1093/0) The index 1 is out of range."The index 1 is out of range"  
      

    Help required,

    Thanks Team !!!


    #webMethods-General
    #Integration-Server-and-ESB
    #webMethods


  • 2.  RE: Dynamic SQL

    Posted Mon October 13, 2014 11:57 AM

    What are you trying to do in a dynamic SQL? Can you share the details/requirements please?


    #webMethods-General
    #webMethods
    #Integration-Server-and-ESB


  • 3.  RE: Dynamic SQL

    Posted Tue October 14, 2014 03:56 AM

    Steps :

    1. Create a dynamic SQL adapter service - which will get 2 inputs at run time
    2. In a flow service, invoke above dynamic SQL adapter service by passing 2 inputs
    3. At this point, I’m getting below mentioned error.

    Thanks


    #Integration-Server-and-ESB
    #webMethods-General
    #webMethods


  • 4.  RE: Dynamic SQL

    Posted Tue October 14, 2014 04:07 AM

    DynamicSQL statement?


    #webMethods
    #Integration-Server-and-ESB
    #webMethods-General


  • 5.  RE: Dynamic SQL

    Posted Tue October 14, 2014 06:38 AM

    Yup, Dynamic SQL

    I select a new DynamicSQL template while creating a new adapter service connection.

    Thanks.


    #webMethods-General
    #Integration-Server-and-ESB
    #webMethods


  • 6.  RE: Dynamic SQL

    Posted Tue October 14, 2014 06:42 AM

    Yup, Dynamic SQL

    While creating a new Adapter service connection, I select a DynamicSQL template and create it. In that , 2 parameters are passed at run time. I’ve defined them also.

    Thanks.


    #webMethods
    #Integration-Server-and-ESB
    #webMethods-General


  • 7.  RE: Dynamic SQL

    Posted Wed October 15, 2014 06:28 AM

    A dynamic SQL is for passing whole parts of SQL which are generated at runtime. For passing parameters you do not need to us dynamic SQL. Select a standard SQL template (select, insert, update) and just define the required inputs in the where or insert clause. This Way the required signature of the service is generated automatically. For complex SQL you may use custom SQL.

    P.S.: Please post you questions to the appropriate forums, this here is just the welcome and introdtuction, not for technical questions.


    #webMethods-General
    #webMethods
    #Integration-Server-and-ESB


  • 8.  RE: Dynamic SQL

    Posted Fri October 17, 2014 04:45 PM

    The best way to execute any SQL is through Stored procedures, because they are pre-compiled and easy to maintain.

    Create an Stored procedure with the requred parameters and call the SP From WM.


    #Integration-Server-and-ESB
    #webMethods-General
    #webMethods


  • 9.  RE: Dynamic SQL

    Posted Sat October 18, 2014 02:47 AM

    I don’t think so :slight_smile:

    You can also use the custom SQL to execute your SQL statements.


    #webMethods
    #webMethods-General
    #Integration-Server-and-ESB


  • 10.  RE: Dynamic SQL

    Posted Fri May 06, 2016 08:34 PM

    Can we make a dynamic sql adapter template which takes in 2 inputs one is the actual variable value and the other one would be a dynamic variable name…

    example below:

    select is_freight from s_equipment se INNER JOIN shipment_s_equipment_join ssej ON ssej.s_equipment_gid = se.s_equipment_gid
    where ssej.${stop_type} = ? and ssej.shipment_gid = ?

    inputs:
    stop_type
    stop_num
    shipment_gid

    values
    DROPOFF_STOP_NUM
    6
    XYZ

    Expected result:(SQLStatement)
    select is_freight from s_equipment se INNER JOIN shipment_s_equipment_join ssej ON ssej.s_equipment_gid = se.s_equipment_gid
    where ssej.DROPOFF_STOP_NUM = ‘6’ and ssej.shipment_gid = ‘XYZ’

    Getting Error:

    (99999/17003) Invalid column index"
    Invalid column index


    #webMethods-General
    #Integration-Server-and-ESB
    #webMethods


  • 11.  RE: Dynamic SQL

    Posted Sat May 07, 2016 10:21 AM

    Hello – please try below one.

    select is_freight from s_equipment se INNER JOIN shipment_s_equipment_join ssej ON ssej.s_equipment_gid = se.s_equipment_gid
    where ssej.${stop_type} = ${VALUE1} and ssej.shipment_gid = ${VALUE2}

    Let me know if you see any issues.

    Thanks,


    #webMethods
    #webMethods-General
    #Integration-Server-and-ESB


  • 12.  RE: Dynamic SQL

    Posted Sun May 08, 2016 09:54 PM

    No luck, again getting same exception…

    But this time A/s was able to substitute the values correctly in query…

    com.wm.app.b2b.server.ServiceException: [ART.117.4002] Adapter Runtime (Adapter Service): Unable to invoke adapter service XYZ.adapters:checkFreightedShipments.
    [ADA.1.316] Cannot execute the SQL statement “select is_freight from s_equipment se INNER JOIN shipment_s_equipment_join ssej ON ssej.s_equipment_gid = se.s_equipment_gid
    where ssej.DROPOFF_STOP_NUM = 6 and ssej.shipment_gid = 123456-SMMULTISTOP1”. "
    (99999/17003) Invalid column index"
    Invalid column index


    #webMethods-General
    #Integration-Server-and-ESB
    #webMethods


  • 13.  RE: Dynamic SQL

    Posted Sun May 08, 2016 09:55 PM

    No luck, again getting same exception…

    But this time A/s was able to substitute the values correctly in query…

    com.wm.app.b2b.server.ServiceException: [ART.117.4002] Adapter Runtime (Adapter Service): Unable to invoke adapter service XYZ.adapters:checkFreightedShipments.
    [ADA.1.316] Cannot execute the SQL statement “select is_freight from s_equipment se INNER JOIN shipment_s_equipment_join ssej ON ssej.s_equipment_gid = se.s_equipment_gid
    where ssej.DROPOFF_STOP_NUM = 6 and ssej.shipment_gid = 123456-SMMULTISTOP1”. "
    (99999/17003) Invalid column index"
    Invalid column index


    #Integration-Server-and-ESB
    #webMethods
    #webMethods-General


  • 14.  RE: Dynamic SQL

    Posted Mon May 09, 2016 01:18 PM

    I tried, it worked for me. Please cross check once again.

    Thanks,


    #Integration-Server-and-ESB
    #webMethods
    #webMethods-General


  • 15.  RE: Dynamic SQL

    Posted Mon May 09, 2016 05:50 PM

    ${VALUE2} appears to be alphanumeric. Put single quotes around it in your query.

    Percio


    #webMethods
    #webMethods-General
    #Integration-Server-and-ESB


  • 16.  RE: Dynamic SQL

    Posted Mon May 09, 2016 06:30 PM

    Just did a small change and now its working for me…

    Earlier i’ve used three input feilds, but for dynamic variables there is no need to define inputs as ‘VARCHAR’ or something else. The Adapter template by default adds dynamic inputs to input document type like (stop_type) here…which can be substituted with PICKUP_STOP_NUM or DROPOFF_STOP_NUM

    So now i’ve changed the other two variables to regular types and defined only first one as dynamic(stop_type)

    inputs:

    stop_num
    shipment_gid

    select is_freight from s_equipment se INNER JOIN shipment_s_equipment_join ssej ON ssej.s_equipment_gid = se.s_equipment_gid
    where ssej.${stop_type} = ? and ssej.shipment_gid = ?


    #webMethods-General
    #Integration-Server-and-ESB
    #webMethods


  • 17.  RE: Dynamic SQL

    Posted Thu May 12, 2016 02:41 PM

    Yes, in general we don’t give input, output datatype details as part of dynamic SQL’s. Going forward when you are reporting any issue, kindly attach snapshots which gives us some clarity, we can also better assist. Thanks anyways for fixing the issue.

    Thanks,


    #webMethods-General
    #Integration-Server-and-ESB
    #webMethods