Setting multiple values in a preparedStatement

Hi all, I am working on an application that has a couple of methods that use the same preparedStatement multiple times (in one case 6 or 7 times), (there is also more than 1 preparedStatement in the method) and I was wondering if there is a simple way to set up to 10 seperate variables in the preparedStatement without doing them line by line (as this is making for quite large methods. I have thought about making it into a seperate method, but that may not be possible due to the intergration of the method (there is a signicant amount of if this then that else if this and this that etc). I could make the methods seperate and pass around resultset but that has been mentioned in the past to be dangerous - Not to mention it will add more of a slowdown to an already troublesome bottleneck.
thanks for any thoughts on the matter.

jschell just chill! just chill! chillout chap!
http://www.smart-it-consulting.com/article.htm?node=99
this link was related to the progress database that
akin was looking out
for. This link was not related anyway with the
coding idea he requested.
and regarding coding its an idea to help ! if you
dont like I have another one to present. If u dont
like that then ...
//Golbal variable declaration
Connection con="";
PreparedStatement ps="";
ResultSet rs="";
purbilc void yourmethod(arg1,....arg10) throws
SQLException
try
con=Drivermanager.getConnection("your driver");
ps = con.prepareStatement("");
ps.setXXX(1,arg1);
ps.setXXX(10,arg10);
ps.executeQuery();
catch(Exception e)
e.printStackTrace();
ile(rs.next())
//retrieve the stuff and store them in an
arrayList for global use
finally
if(con!=null)
try
con.close();
con=null;
catch(Exception e)
e.printStackTrace();
}call yourmethod one time routine n number of times in
your methods .
Akin if it suits well and works out dont forget to
give me energy dollars(dukes) :))So your solution is to put all the information from a database into a bunch of arraylist and then start comparing the arraylists ? That more or less defeats the purpose of the database.
Ps. When working with databases you can't be guarenteed that the driver will take care of closing all your resources properly for you so you are best off to close them yourself (Those being the connection, the result set and the preparedStatement).
PPs. The duke dollars are worthless, they can't buy anything, and they certainly aren't energy. The only thing they offer is a token of appreciation for a provided answer. Also heed jschell's advice, don't try and give out advice on things that you don't have a full understanding on, or at the very least make it known that you are providing an answer that may not be the best suited for it.

Similar Messages

  • How to set multiple values in one context-attribute

    Hi all,
    Anybody knows a possibility to set multiple Values to a context-attribute?
    I know it how to get it with the following code:
    String break[]= request.getParameterValues("break");
    Now I want to do something like:
    request.setParameterValues(break[no]);
    where no is a counter in a loop.
    With the Method setAttribute(), I overwrite the previous inserted value.
    Thanx
    Robert

    I have not explizit declared break as an array.
    It is the Context- Attribute I want to send. I thaught that I can use it as an array in the same way I can do it when I send Data from an HTML- Form (with multiple values) to an servlet.
    I don't know how to declare the Attribute explizit as an array.
    that it is you wanted to know?
    I think my main problem is to get an array from the servlet to the jsp. Is there an other possibility (other than via Context-Attributes) to do that?
    thanx
    robert

  • Updating/setting multiple values in lookup field through powershell

    I'm trying to set multiple values to lookup column. I can get it to set one value but multiple values don't work
    see below
    [Microsoft.SharePoint.SPFieldLookupValueCollection] $itemValues = New-Object Microsoft.SharePoint.SPFieldLookupValueCollection
    [Microsoft.SharePoint.SPFieldLookupValue] $lookupvalue = New-Object Microsoft.SharePoint.SPFieldLookupValue
    $lookupvalue.LookupId = 1
    $lookupvalue.LookupId = 2
    $itemValues.Add($lookupvalue)
    $CMRSItems["Event Type"] = $itemValues
    $CMRSItems.Update()
    I was expecting the LookupID 1 and 2 to update but it doesn't. When i specify LookupId = 1 it works
    What am i doing wrong.
    Thanks in Advance

    Hi Patrick, 
    In your script above you're using the same object to set both ID's on. Setting the ID of $lookupvalue, then adding it to the lookupvaluecollection, before changing the ID value to 2, then adding that to the collection. 
    I wrote an article on setting fields using PowerShell, but it doesn't include multiple lookup values. It does contain multiple choice and taxonomy values though, which is a similar concept. It's here if you want to take a look: http://social.technet.microsoft.com/wiki/contents/articles/20831.sharepoint-a-complete-guide-to-getting-and-setting-fields-using-powershell.aspx
    Regards, Matthew
    MCPD | MCITP
    My Blog
    View
    Matthew Yarlett's profile
    See my webpart on the TechNet Gallery that allows administrative users to upload, crop and format user profile photos. Check it out here:
    Upload and Crop User Profile Photos

  • How do you set multiple values in "Internal-Properties" in XSLT

    Hi All,
    I'm running SOA 11g with the Oracle B2B Adapter.
    I have a need to dynamically set the InterchangeReceiverID, InterchangeSenderID, GroupSenderID, and GroupReceiverID from within SOA prior to passing the xml to the B2B Adapter. When using the Transform Activity, I don't understand how to set multiple values at the Interchange/Group levels. I am able to set ONE value at each level using the structure below, but have not been able to determine the proper way to set more than one value at each level.
    Any help would be appreciated.
    thanks,
    bw
    <ns4:Internal-Properties>
    <ns4:Data-Structure>
    <xsl:attribute name="Name">
    <xsl:text disable-output-escaping="no">Interchange</xsl:text>
    </xsl:attribute>
    <ns4:Lookup>
    <xsl:attribute name="Name">
    <xsl:text disable-output-escaping="no">InterchangeSenderID</xsl:text>
    </xsl:attribute>
    <xsl:text disable-output-escaping="no">1234</xsl:text>
    </ns4:Lookup>
    <ns4:Data-Structure>
    <xsl:attribute name="Name">
    <xsl:text disable-output-escaping="no">Group</xsl:text>
    </xsl:attribute>
    <ns4:Lookup>
    <xsl:attribute name="Name">
    <xsl:text disable-output-escaping="no">GroupSenderID</xsl:text>
    </xsl:attribute>
    <xsl:text disable-output-escaping="no">5678</xsl:text>
    </ns4:Lookup>
    <ns4:Data-Structure>
    <xsl:attribute name="Name">
    <xsl:text disable-output-escaping="no">Transaction</xsl:text>
    </xsl:attribute>
    <ns4:Lookup>
    <xsl:attribute name="Name">
    <xsl:text disable-output-escaping="no">TransactionID</xsl:text>
    </xsl:attribute>
    <xsl:text disable-output-escaping="no">856</xsl:text>
    </ns4:Lookup>
    </ns4:Data-Structure>
    </ns4:Data-Structure>
    </ns4:Data-Structure>
    </ns4:Internal-Properties>

    Hi Anuj,
    Thanks for taking time to consider this. I think I did not explain my problem clearly. I'm not trying to assign more than one value to any one property. My issue is that I cannot figure out the proper syntax within the XSLT to assign a value to more than one property at the Interchange level. For instance, do you have an example of how I would assign one value to the InterchangeSenderID and another value to the InterchangeReceiverID? Constant values (rather than dynamic ones) would be fine for an example. Thanks again for your time.
    thanks,
    bw

  • Set multiple values in a web template via JavaScript

    Hi,
    I have a web template displaying a query containing a mandatory variable. Multiple values are allowed for the variable.
    By manually inserting a link in the template I succeeded in setting a single value for the variable with JavaScript, but how is it possible to pass multiple values for that variable?
    So far my link target looks like this:
    "sap/bw/BEx?sap-language=EN&bsplanguage=EN&CMD=LDOC&
    TEMPLATE_ID=ZJS_WT_1&VAR_NAME_1=ZJS_V_R&VAR_VALUE_EXT_1=1"
    How do I have to modify the line?
    Cheers,
    Jost

    Jost -
    I haven't tried this yet...but I suspect it could work. In the below example, I have a variable on Company Code and am setting it equal to 3 different values. Give it a shot.
    &CMD=PROCESS_VARIABLES&SUBCMD=VAR_SUBMIT
    &VAR_ID_1=ZCCMPCOD0001
    &VAR_ID_2=ZCCMPCOD0001
    &VAR_ID_3=ZCCMPCOD0001
    &VAR_OPERATOR_1=EQ
    &VAR_VALUE_LOW_EXT_1=IP01
    &VAR_VALUE_HIGH_EXT_1=
    &VAR_SIGN_1=I
    &VAR_OPERATOR_2=EQ
    &VAR_VALUE_LOW_EXT_2=IP05
    &VAR_VALUE_HIGH_EXT_2=
    &VAR_SIGN_2=I
    &VAR_OPERATOR_3=EQ
    &VAR_VALUE_LOW_EXT_3=IP50
    &VAR_VALUE_HIGH_EXT_3=
    &VAR_SIGN_3=I

  • Setting Multiple values in property set using java API

    Hello All,
    I want to set the properties of a profile in a property set using java API provided
    in package p13n. The property can have multiple values. When I try to add the
    property using ProfileManager.setProperty() method. But every time I do it this
    way, it replaces the earlier value of property and not added. This, I can achieve
    using portalTools but I want to use the API for user registration on the site.
    I hope the query is clear.
    Waiting for a response,
    Thanks in advance,
    Shrinivas

    You need to use java.util.ArrayList.
    First cast the existing value into ArrayList using getProperty method,
    change values in the ArrayList and then put them back with setProperty
    method.
    Regards,
    Michael Goldverg
    "Shrinivas Rao" <[email protected]> wrote in message
    news:3d64e7d9$[email protected]..
    >
    Hello All,
    I want to set the properties of a profile in a property set using java APIprovided
    in package p13n. The property can have multiple values. When I try to addthe
    property using ProfileManager.setProperty() method. But every time I do itthis
    way, it replaces the earlier value of property and not added. This, I canachieve
    using portalTools but I want to use the API for user registration on thesite.
    I hope the query is clear.
    Waiting for a response,
    Thanks in advance,
    Shrinivas

  • Setting multiple values in a cookie

    I am trying to create a cookie with multiple values.But it is giving me javascript error "Object expected" i am not able to figure out what's the problem.Can anybody help!
    <html>
    <head>
    <script language="javascript">
    function on_submit(){
         var testArray = new setCookieArray("Hello","Testing","cookie");
    var expdate = new Date();
    expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
    function setCookieArray(name){
         this.length = setCookieArray.arguments.length - 1;
    for (var i = 0; i <= this.length; i++) {
    data = setCookieArray.arguments[i+1] <--Error
    setCookie (name + i, data, expdate);
    </script>
    </head>
    <body >
    <form name="cookietest">
    <input type="button" value="Submit" onClick="on_submit();">
    </form>
    </body>
    </html>

    Few changes,
    <script language="javascript">
    <!--
    function on_submit() {
         var values = ["Hello","Testing","cookie"];
         var testArray = new setCookieArray(values);
    function setCookieArray(name) {
         var expdate = new Date();
         expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
         var len = name.length;
         for (var i = 0; i < len; i++) {
              data = name[ i ];
              setCookie (name[ i ] + i, data, expdate);
    // -->
    </script>Hope this helps.
    Sudha

  • Setting multiple values for query prompt: In List...

    Dear All,
    I have used "Radio Button" component which has labels like A, B and C. If user selects A then Radio button save 10 as its value on Excel and which being used in queries prompts. If user select B then Radio button save 20 on Excel at Destination cell and all queries use this for prompt value. But when user select C which is the for both values 10 and 20. No queries executed successfully, values are in String and I tried following values for C in excel
    "10,20"
    10,20
      '10,20'
    10;20
    '10','20'
    10 20
    But when I execute this query at Dashboard Query Panel and selects both 10 and 20 as Inputs since I'm using In List operator then the query executes perfectly. See below the query:
    SELECT   Table__1."0CALMONTH",   SUM(Table__1."0INV_QTY"),   SUM(Table__1."0NETVAL_INV"),   Table__1."0DOC_CURRCY" FROM   "SD_C_ZSDIC"."PUBLIC"."IC_ZSDIC"  Table__1 WHERE   (    Table__1."0CALDAY"  BETWEEN  {d '2014-01-01'}  AND  {d '2014-06-13'}    AND    Table__1."0ACCNT_GRP"  =  'ZLOC'    AND    Table__1."0COMP_CODE"  =  '1000'    AND    Table__1."0MATERIAL__0DIVISION"  IN  ('10','20')    AND    Table__1."0CALMONTH"  <>  0    AND    Table__1."REFERENCE_DATE"  =  {d '2014-06-13'}   ) GROUP BY   1,    4 HAVING   SUM(Table__1."0INV_QTY")  <>  0 ORDER BY   1
    1. In which format I should save value of C, so that I can have '10','20' for the query prompts value?
    2. Am I missing something or my format of C values at Excel sheet is not correct on?
    I will appreciate your reply in this regard.
    Many thanks!!!
    Tariq Ashraf

    put the output of C
    in 2 cell
    for eg
    C1=10
    C2=20
    and map the 0MATERIAL__0DIVISION(prompt) to cell C1 and C2
    NOTE
    we have to write  formula in C1 and C2
    C1 = if radiobutton=b then 20 else 10.
    C2 = if radiobutton=c then 20 else ""
    map both cell c1 and c2 to the list prompt
    it will work

  • Set cell value performance...

    Hi,
    I'm trying to find out if any of you have a faster way of setting values in Matrix as for any System cell value like ItemCode, not just UDF's
    My actual code looks like that but I'm wondering if there's a faster way as right now, it is slow and having to set multiple values in matrix makes the addon very slow and unacceptable by customers
    public static object SetCellValue(SAPbouiCOM.Matrix Matrix, object ColumnUID, int Row, object Value)
        SAPbouiCOM.Column Column = Matrix.Columns.Item(ColumnUID);
        SAPError = "";
        object Cell = null;
        switch (Column.Type)
            case (SAPbouiCOM.BoFormItemTypes.it_EDIT):
            case (SAPbouiCOM.BoFormItemTypes.it_EXTEDIT):
            case (SAPbouiCOM.BoFormItemTypes.it_LINKED_BUTTON):
                SAPbouiCOM.EditText Editor = (SAPbouiCOM.EditText)Column.Cells.Item(Row).Specific;
                Cell = Editor;
                Editor.Value = Value.ToString();
                break;
            case (SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX):
                SAPbouiCOM.ComboBox ComboBox = (SAPbouiCOM.ComboBox)Column.Cells.Item(Row).Specific;
                Cell = ComboBox;
                ComboBox.Select(Value, SAPbouiCOM.BoSearchKey.psk_ByDescription);
                break;
            case (SAPbouiCOM.BoFormItemTypes.it_CHECK_BOX):
                SAPbouiCOM.CheckBox chk = (SAPbouiCOM.CheckBox)Column.Cells.Item(Row).Specific;
                Cell = chk;
                chk.Checked = bool.Parse(Value.ToString());
                break;
        return Cell;

    Hi Marc,
    The new method GetCellSpecific of the matrix object is much faster than casting a cell to a particular control type using its Specific property:
    SAPbouiCOM.EditText Editor = (SAPbouiCOM.EditText)Matrix.GetCellSpecific(ColumnUID, Row);
    This should be noticeably faster than the older method and works for system matrices as well as user-defined ones.
    Kind Regards,
    Owen

  • Setting the value of a single attribute for multiple line items

    Hi all,
    I am working on a Web Dynpro application, I have created this applicaion for an accounting document so it has header data and multiple line item data. As per the requirement I have to put the following logic:
    1. When a user enters a value in the field KBLNR on the line item, all the other fields like cost centerm fund, functional area should populate from a database table based on the value of the KBLNR. to get this I have put the following code:
    TYPES: BEGIN OF t_kblp,
              fipos     TYPE kblp-fipos,
              kostl     TYPE kostl,
                      END OF t_kblp.
      DATA lv_kblnr TYPE wd_this->element_t_bseg-kblnr.
      DATA: lt_kblp TYPE STANDARD TABLE OF t_kblp,
            wa_kblp LIKE LINE OF lt_kblp,
            lt_bseg              TYPE STANDARD TABLE OF bseg,
            wa_bseg              TYPE bseg.
      DATA lo_nd_t_bseg TYPE REF TO if_wd_context_node.
      DATA lo_el_t_bseg TYPE REF TO if_wd_context_element.
      DATA: ls_t_bseg TYPE wd_this->element_t_bseg,
            lo_api_controller    TYPE REF TO if_wd_controller,
            lo_message_manager   TYPE REF TO if_wd_message_manager,
            lo_nd_tbseg          TYPE REF TO if_wd_context_node,
             lo_el_tbseg          TYPE REF TO if_wd_context_element,
             lt_el_tbseg          TYPE wdr_context_element_set,
             lv_bseg              TYPE bseg.
      lo_nd_t_bseg = wd_context->path_get_node( path = `ZDATA.CHANGING.T_BSEG` ).
      lo_api_controller ?= wd_this->wd_get_api( ).
      CALL METHOD lo_api_controller->get_message_manager
        RECEIVING
          message_manager = lo_message_manager.
      lo_nd_tbseg = wd_context->path_get_node( path = `ZDATA.CHANGING.T_BSEG` ).
      lt_el_tbseg = lo_nd_tbseg->get_elements( ).
      LOOP AT lt_el_tbseg INTO lo_el_tbseg.
        lo_el_tbseg->get_static_attributes(
                               IMPORTING static_attributes = lv_bseg ).
      IF lv_bseg-kblnr NE ' '.
          SELECT belnr
                 fipos
                 kostl
                 PSPNR
                 geber
                 saknr
                 fkber
                 grant_nbr
                 gsber
                 FROM kblp
                 inTO corresponding fields of wa_kblp
                 WHERE belnr = lv_bseg-kblnr and
                      saknr = lv_bseg-saknr.
            ENDSELECT.
    lo_nd_t_bseg = wd_context->path_get_node( path = `ZPRELIMINARY_POSTING.CHANGING.T_BSEG` ).
    * get element via lead selection
            lo_el_t_bseg = lo_nd_t_bseg->get_element( ).
    lo_el_tbseg->set_static_attributes(
                               EXPORTING static_attributes = wa_kblp ).
       CLEAR: lv_bseg, wa_kblp.
      ENDLOOP.
    everything is working fine but now the problem is couple of fields that I have in wa_kblp are with different names in bseg table and hence they are not updating... I tried putting the following logic within the loop :
    lo_el_t_bseg->set_attribute(
        name =  `PROJK`
    value = wa_kblp-pspnr ).
    but it's only setting the value of the first line item and not working for the multiple line items, can you please tell me how can do this?
    Thanks,
    Rajat Garg
    Edited by: rajatg on Jun 24, 2011 5:09 PM

    Hi Chris,
    I tried your code and it worked fine but after I put this code I am getting another issue. within the loop I had a code to make the fields non modifiable on the screen and was working fine but now what's happening is it's making the all the lines uneditable except the one with data on it (which is completely opposite), this is what I have coded:
    LOOP AT lt_el_tbseg INTO lo_el_tbseg.
        lo_el_tbseg->get_static_attributes(
                               IMPORTING static_attributes = lv_bseg ).
    IF lv_bseg-kblnr NE ' '.
      SELECT belnr
                 fipos
                 kostl
                 PSPNR
                 geber
                 saknr
                 fkber
                 grant_nbr
                 gsber
                 FROM kblp
                 inTO corresponding fields of wa_kblp
                 WHERE belnr = lv_bseg-kblnr and
                      saknr = lv_bseg-saknr.
            ENDSELECT.
    move: wa_kblp-belnr to wa_bseg-kblnr,
    wa_kblp-fipos to wa_bseg-fipos,
    wa_kblp-kostl to wa_bseg-kostl,
    wa_kblp-pspnr to wa_bseg-projk,
    wa_kblp-geber to wa_bseg-geber,
    wa_kblp-saknr to wa_bseg-saknr,
    wa_kblp-fkber to wa_bseg-fkber,
    wa_kblp-grant_nbr to wa_bseg-grant_nbr,
    wa_kblp-gsber to wa_bseg-gsber,
    lv_bseg-dmbtr to wa_bseg-dmbtr.
    append wa_bseg to lt_bseg.
    lo_nd_edit_property = wd_context->path_get_node( path = `ZPRELIMINARY_POSTING.CHANGING.T_BSEG.EDIT_PROPERTY` ).
          get element via lead selection
          lo_el_edit_property = lo_nd_edit_property->get_element( ).
          lo_el_edit_property->set_attribute(
            name =  `EDIT_FIELD`
            value = 'ABAP_TRUE' ).
          lo_el_edit_property->set_attribute(
            name =  `EDIT_WBS`
            value = 'ABAP_TRUE' ).
    endif.
    endloop.
    o_nd_t_bseg = wd_context->path_get_node( path = `ZPRELIMINARY_POSTING.CHANGING.T_BSEG` ).
    get element via lead selection
            lo_el_t_bseg = lo_nd_t_bseg->get_element( ).
      CALL METHOD lo_nd_t_bseg->bind_table
        EXPORTING
          new_items            = lt_bseg.
    Can you please see what I am doing it wrong here....

  • Setting Default Values in PO - Multiple Account Assignment

    Hello Experts,
    How do we set defalut values for the Field "Partial Invoice" in the Account Assignment Tab(Multiple Acc Assignment) of Purchase Order/Purchase Requisistion.
    This field is  not available in Personal settings of "PO Item", also there is no "Parameter ID" available for this field.
    Regards,
    Hemant Kumar B

    Hi,
    The suggestion provided was useful, but it is a client level setting. Is there a way to have the value for the field defaulted as a user setting.
    Regards,
    Hemant Kumar B

  • Gauges: Setting multiple intervals values

    Hi,
    I have following report:
    ASL Budget Spend Amount
    1 100$ 200$
    2 200$ 150$
    and I've created a gauge view based on "Spend Amount" measure.
    Now, I see two gauges, one for each row. If I set intervals values, they are common to both rows. Can I define different intervals values for each row? For example
    For first row interval must be
    Green Range 0 - 150
    Orange Range: 151 - 200
    Red Range: 201 - 300
    For second row interval must be
    Green Range 0 - 150
    Orange Range: 151 - 300
    Red Range: 301 - 320
    So, for first row, gauge indicator must be on Orange Range, on the other hand for second row, indicator must be on Green Range.
    All Regards
    Giancarlo

    Hi,Try the follwing exit:
    Cerate a variable which represents Multiple single values and ready for input.
    replace 001 and 002 with Keys of your characteristic values.
    DATA:L_S_RANGE TYPE RSR_S_RANGESID.
    I_STEP = 1.
    CLEAR L_S_RANGE.
    L_S_RANGE-LOW ='001'.
    L_S_RANGE-SIGN = 'I'.
    L_S_RANGE-OPT = 'EQ'.
    APPEND L_S_RANGE TO E_T_RANGE.
    L_S_RANGE-LOW = '002'.
    L_S_RANGE-SIGN = 'I'.
    L_S_RANGE-OPT = 'EQ'.
    APPEND L_S_RANGE TO E_T_RANGE.
    ENDFUNCTION.

  • Error: Set type Z contains multiple-value attributes

    Hi forum,
    I have a problem when i try to assign a set type with the same value but diferent name on another set type to the same product category.
    This is the detail of the error but i dont know where i have to set this indicator:
    If you set this indicator for a particular hierarchy, all categories and set types in this hierarchy are created in the PME.
    This gives you the following extended maintenance options at category level:
    You can assign set types with multiple-value attributes
    You can restrict value ranges and maintain default values for attributes of customer set types.
    Any sugerence about this?
    Regards and thanks in advance,
    Mon

    Hi Nelson,
    I create two set types, the description is not the problem. I have discover that when i try to assign these attributes in the same set type or in other appears this error.
    The set types have the same values. For example:
    zcountry1. Values: sp - spain. fr - france.
    zcountry2. Values: sp - spain. fr - france.
    When i try to configurate the comm_hierarchy in my category appears this error:
    Set type zcountry2 contains multiple-value attributes.
    Diagnosis
    The set type ZGAME5 contains multiple-value attributes. It cannot be assigned to the category as extended maintenance has not been activated.
    Procedure
    Multiple-value attributes are stored in the PME. If you want to use the set type ZGAME5, you must set the Extended Maintenance Options indicator for the hierarchy.
    Extended Maintenance Is Possible for the Hierarchy
    Definition
    If you set this indicator for a particular hierarchy, all categories and set types in this hierarchy are created in the PME.
    This gives you the following extended maintenance options at category level:
    You can assign set types with multiple-value attributes
    You can restrict value ranges and maintain default values for attributes of customer set types.
    Where is this indicator¿? in R3?
    So, these are the steps...can anybody help to me?
    Regards and thanks in advance.

  • Binding multiple values for a clause in a PreparedStatement

    Is there a way to bind multiple values for the same variable?
    Example: select * from catalog where catnum = ?
    and cat_num can be 12340-56, 23451-21 43211-00 etc.
    so the where condition really is:
    catnum in ('12340-56', '23451-21', '43211-00')
    Thanks for a lead!

    I've not been able to do this in a way I'd call clean. You might think you could do something like:// create a PreparedStatment with
    // the following String: select * from catalog where catnum in (?)"
    ps.setString(1, "'12340-56', '23451-21', '43211-00'");But the driver tends to escape the stuff you want to go "straight in" to your where clause. So I end up using Statement and building the SQL manually.
    I'd be interested in anyone else's solution
    Lee

  • Setting multiple parameters in "ON VALUE-REQUEST FOR"

    Hello experts,
    I have a dynpro with two parameters on it, called PA_LABKY and PA_LABTX. The first field PA_LABKY is extended by a value help (see the code below). Normally when a user chooses a value from f4 help the field is filled with the value. That works correct. Now not the first but both fields PA_LABKY and PA_LABTX should be filled when the user chooses a value from f4 help.
    I tried it with following code:
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_labky.
    get the values from database
      SELECT * FROM zrec_001t INTO TABLE lt_rec001t.
    set the first output field
      CLEAR ls_dynfieldmap.
      ls_dynfieldmap-fldname = 'LABKY'.
      ls_dynfieldmap-dyfldname = 'PA_LABKY'.
      APPEND ls_dynfieldmap TO lt_dynfieldmap.
    set the second output field
      CLEAR ls_dynfieldmap.
      ls_dynfieldmap-fldname = 'LABTX'.
      ls_dynfieldmap-dyfldname = 'PA_LABTX'.
      APPEND ls_dynfieldmap TO lt_dynfieldmap.
    display the f4 help
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          ddic_structure  = 'ZREC_001T'
          retfield        = 'LABKY'
          value_org       = 'S'
        TABLES
          value_tab       = lt_rec001t
          return_tab      = lt_returntab
          dynpfld_mapping = lt_dynfieldmap
        EXCEPTIONS
          parameter_error = 1
          no_values_found = 2
          OTHERS          = 3.
    the first row contains the value for PA_LABKY
      READ TABLE lt_returntab INDEX 1 INTO ls_returntab.
    set the value on the dynpro
      pa_labky = ls_returntab-fieldval.
    the second row contains the value for PA_LABTX
      READ TABLE lt_returntab INDEX 2 INTO ls_returntab.
    set the value on the dynpro 
    move ls_returntab-fieldval to pa_labtx. "  <--- NOW THAT DOESN'T WORK
    It's the last row that doesn't work, it nothing happens with this field. How can I fill that field?
    Thanks in advance.
    Daniel

    In order to set the second field you must use the function module DYNP_VALUES_UPDATE.  Replace that last statement with a call to this function module,  you must pass the parameter name and the value.
    Regards,
    RIch Heilman
    Correct function module name
    Message was edited by:
            Rich Heilman

Maybe you are looking for