PreparedStatement, SELECT...WHERE FIELD_ABC IN (?,?,?) Number of ? not fix

Hi,
I want to use the PreparedStatement for a SELECT Query, The SELECT query has a where clause in which there is a condition like:
WHERE FIELD_ABC IN (?,?,?) AND FIELD_XYZ=?
The number of parameters passed in IN clause are not fixed and they are changing dynamically so I can not put fixed number of '?' in the query.
Please help me with ideas of achieving the advantages of PreparedStatement for SELECT query with IN clause. Is there some way to achieve this? Can I pass an Array of values for parameters of IN Clause?

>
What?! That definitely will NOT work.
The only hope you have is to build up a query with the
appropriate number of "?"s. Have two strings, one for
the prefix part (everything upto the "IN ("), and one
for the suffix (everything including and after the
Then write a little loop that appends the appropriate
number of "?, " to the prefix (and take care to not
have an extra "," after the last one), and then append
the suffix, and prepare that query.good luck preparing the a query every time you send one, so why prepare it?!
>
Other ideas: insert the values into a temporary table
with one column, and join the column (that you have in
the IN clause) to that table.
So again, every time you execute a query, you will execute multiple 'insert' queries for it. wonderful!
I'd say if you are most of the time having like 3 values inside the IN cluase, prepare a query that has (?,?,?) and when you send an actual query check if you have 3 values, use it, otherwise just execute the query.
This can be generalized, assume that one third of your queries have 2 values, another one third have 3 values, and the rest of the queries have various number of values inside the IN clause, In this case you prepare two queries, first with (?,?), second with (?,?,?). When you have a query, decide which prepared query to use or if you just send unprepared query.
This approach however does not help if the number of values inside the IN clause in your queries is uniformly distributed over a large range
>
This would be a very useful JDBC addition, by the way:
a JDBC escape to handle IN clauses (just like the JDBC
clauses to handle outer joins, etc.)

Similar Messages

  • Sales Order number is  not showing in MD04

    Hi Gurus  ,
    I have got one case where  Sales order number is not showing  in MD04 screen  . This sales order , line item  has already delivered , PGI &  billing document also been generated  . Moreover accounting document is also been created .As cheeked & found that it is not shwoing in MD04 screen  because at  the time sales order creation  availability check “01” was maintained  which has sum up all the  requirement in one  particular day ( Also as
    per SAP note -70408) .
    Now because  all the subsequent document has been generated  for sales order so we can not mark it for “Rejection for rejection “  & to create new  sales order  with  availability check “02” in material master .
    Please let  me know the possible solution for the same or  if any  sap note would  be required to get the sales order number in MD04  .
    Thanks  ,
    Aman

    Hi Kiran ,
    Actually  before running the  report in “SDRQCR21”  in PRD I wanted to  run it in “Quality “ .
    In quality I am not able to simulate the same  .
    Please refer below points related to my testing result .
    1.Mainatined availability check group “01” .
    2 . Created Sales order 
    3. Check in MD04 screen & as expected  sales order  was coming blank  with negative Qty .
    4. Run the MRP which generated PR
    5. PR converted to PO  & GRN was done which updated the stock
    6. Created delivery  & checked the same in MD04  . It was also coming blank  . No delivery  document  numbe was showing in screen  but  it was coming with negative  Qty .
    7. Done the PGI  & blank  delivery document number  was removed & it become  normal .
    In PRD .
    There are 3 sales order
    One sales order is already marked reason for rejection & two sales order delivery , PGI has been done  .
    But still it is showing  blank sales order with negative Qty  & after MRP run it is generating the PR also  .
    I don't why it was  showing with negative values  .
    Please refer attacehed screen shot  .
    Thanks,
    Regards ,
    Aman

  • Select where Ken Burns into?

    On Windows Movie Maker, I could select the location where the KBE would zoom into. As far as I can tell, iMovie does it automagically. Is there a way to select where to apply the KBE (not on/off or zoom in/out)?
    Thanks

    Also, click on the rectangle to toggle between the red rectangle and the green rectangle.

  • Insert statement will not work if select statement has less number of colum

    Hi,
    One of my thread is already resolved on the following URL : unable to insert rows into the table
    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM CASE_101 WHERE 1=2;
    DECLARE
    S VARCHAR2(200);
    STMT VARCHAR2(500);
    begin
    for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CASE%' TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
    STMT := 'INSERT INTO TEMP SELECT * FROM ';
    STMT:=STMT || C.TABLE_NAME;
    EXECUTE IMMEDIATE STMT;
    dbms_output.put_line(c.table_name);
    end loop;
    end;
    i am facing now some different; almost all the tables have same number of columns except in few of tables have some additional columns. As above i am creating a table "TEMP" who has highest column temp(by doing some manual process). The table who has less columns than "TEMP" table : Insert statement will not work. 'INSERT INTO TEMP SELECT * FROM less_columns_table_name'.
    Please let me know , how can i execute proper way.
    Thanks.
    Best Regards
    Arshad

    user13360241 wrote:
    Hi,
    One of my thread is already resolved on the following URL : unable to insert rows into the table
    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM CASE_101 WHERE 1=2;
    DECLARE
    S VARCHAR2(200);
    STMT VARCHAR2(500);
    begin
    for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CASE%' TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
    STMT := 'INSERT INTO TEMP SELECT * FROM ';
    STMT:=STMT || C.TABLE_NAME;
    EXECUTE IMMEDIATE STMT;
    dbms_output.put_line(c.table_name);
    end loop;
    end;
    i am facing now some different; almost all the tables have same number of columns except in few of tables have some additional columns. As above i am creating a table "TEMP" who has highest column temp(by doing some manual process). The table who has less columns than "TEMP" table : Insert statement will not work. 'INSERT INTO TEMP SELECT * FROM less_columns_table_name'.
    Please let me know , how can i execute proper way.
    Thanks.
    Best Regards
    Arshadmore often than not "TEMP" tables are NOT required & are highly inefficient in Oracle.
    Either only specify explicit column in TEMP to get data,
    or provide value for "extra" column in TEMP

  • TS2755 On new IOS 7, when I message contacts, it selects thier old contact number, despite the fact I have deleted/edited their number in my contacts list. IOnly by going through contacts, can I message the correct number. The old number does not appear t

    On new IOS 7, when I message contacts, it selects thier old contact number, despite the fact I have deleted/edited their number in my contacts list. Only by going through contacts, can I message the correct number. The old number does not appear there, so I am unsure where "messages" is picking up the old number, it doesn't appear that "messages" is synching with "contacts". Any ideas how to fix this?

    On new IOS 7, when I message contacts, it selects thier old contact number, despite the fact I have deleted/edited their number in my contacts list. Only by going through contacts, can I message the correct number. The old number does not appear there, so I am unsure where "messages" is picking up the old number, it doesn't appear that "messages" is synching with "contacts". Any ideas how to fix this?

  • TS1702 My iMessage is only allowing me to select messages to be sent and received from my email. If my number is an option, but it will not let me select my number, how do I get the iMessages to be sent to my number and not my email?

    My iMessage is only allowing me to select messages to be sent and received from my email. If my number is an option, but it will not let me select my number, how do I get the iMessages to be sent to my number and not my email?

    Try ejecting your iphone from iTunes and then close iTunes. Now retry. Hope this helps.

  • Data Package 1 : arrived in BW ; Processing : Selected number does not agre

    Hi experts,
    When loading data into PSA via UD Connect, getting the following error:
    Overall status: Errors occurred: or: missing messages   -
    (red light)
    Requests (messages): Everything OK  -
    (green light)
       Data request arranged -
    (green light)
       Confirmed with: 确定  -
    (green light)
    Extraction (messages): Errors occurred  -
    (red light)
       Data request received -
    (green light)
       Data selection scheduled -
    (green light)
       Error occurred in the data selection -
    (red light)
    Transfer (IDocs and TRFC): Missing messages or warnings -
    (yellow light)
      Data Package 1 : arrived in BW ; Processing : Selected number does not agree with transferred n -
    (yellow light)
    Processing (data packet): Everything OK -
    (green light)
      Data Package 1 ( 20000 Records ) : Everything OK -
    (green light)
    Please help me to resolve this problem, thanks in advance.
    Gavin

    Hi,
    You must have the following profiles to BWREMOTE or ALEREMOTE users.So add it. Bcoz either of these two users will use in background to get extract teh data from ECC, so add tehse profiels in BW.
    S_BI-WHM_RFC, S_BI-WHM_SPC, S_BI-WX_RFC
    And also check the following things.
    1.Connections from BW to ECC and ECC to BW in SM59
    2.Check Port,Partner Profiles,and Message Types in WE20 in ECC & BW.
    3.Check Dumps in ST22, and SM21.
    4.If Idocs are stuck i.e see the OLTP Idoc numbers in RSMO Screen in (BW) detials tab see in bottom, you can see OLTP Idoc number and take the Idoc numbers and then goto to ECC see the status in WE05 or WE02, if error then check the log else goto to BD87 in ECC and give the Idoc numbers and execute manually and see in RSMO and refresh.
    5.Check the LUWs struck in SM58,User Name = * (star) and run it and see Strucked LUWs and select our LUW and execute manually and see in RSMO in BW.
    See in SDN
    Re: Loading error in the production  system
    Thanks
    Reddy

  • HT1918 Trying to edit my payment info.  I keep getting the message that my number is not valid for the type of card I have selected.  I have a VISA card.  I have typed in the number 4 times, but same message pops up.

    Trying to edit my payment info.  I keep getting the message that my number is not valid for the type of card I have selected.  I have a VISA card.  I have typed in the number 4 times, but same message pops up.
    Thoughts?

    You are probably entering your Visa's security code incorrectly.  Here's how to find it:
    http://support.apple.com/kb/HT3541

  • BW:  Data Packages Selected number does not agree with transferred

    Hi,
    I am running into an issue with an existing master data text load process chain in Production.  The extractor is from ERP and there are only 159 records.  What is happening is the chain is stuck on yellow but there is an issue with the data packages.  The status error message is 'Missing data packages for PSA table'.  Clicking into the Details tab the message then states Data Package 1:  arrived in BW; Processing:  Selected number does not agree with transferred.
    The version is BI 7.0.  I have done the following steps and still no luck.  Looking for any suggestions.  Thanks.
    ERP
        SM37 (Job always finishes)
        SM58 (No IDOCS stuck)
        ST22 (No short dumps)
    BW
        SM58 (No IDOCS stuck)
        SM37 (Job always finishes)
        ST22 (No short dumps)
    Reactivated Datasource:  RSDS_DATASOURCE_ACTIVATE_ALL
    Reactivated Transformation:  RSDG_TRFN_ACTIVATE

    Hi
    Just check whether source system connection is ok in RSA1.
    if it is fine then have a loo at the below thread(last post)
    Data Load from R/3 to BW-'Selected number does not agree with transferred'
    Regards,
    Venkatesh

  • In the music window of iMovie music selections are shown a number of times. Why? Shouldn't the duplications be deleted? They are not doubled in iToons

    In the music window of iMovie , music selections are shown a number of times. Why? Shouldn't the duplications be deleted? They are not doubled in iToons.
    How does one delete them? How do you avoid duplications in the future?

    Are you referring to the jingles?
    They are available in different lengths; short, medium and long. They also may be available in .CAF and .AIFF formats.
    If you are referring to your songs in iTunes, I have never seen that one before.

  • The below vi is not giving me what I want. If I select 2 with maximum number of 3 then there are 3 array elements display that is correct but if I select 8 with the same maximum number of 3 then only 1 array element display. Why is that?

    The below vi is not giving me what I want. If I select 2 with maximum number of 3 then there are 3 array elements display that is correct but if I select 8 with the same maximum number of 3 then only 1 array element display. Why is that?
    Attachments:
    test2.vi ‏29 KB

    It's because in case 2 you hold the array build result from the previous loop iteration in a shift register...in case 8 you do not...
    You say that if you set the maximum number to three it will produce an array with three elements, that is not correct, it will run when the iteration index is 0,1,2 and 3...resulting in 4 elements. If you want 3 you need to decrement the maximum number to 2. The same goes for case 8.
    MTO

  • LR4 - computer lost hard drive - have serial number where can I download please - not version 5

    I need a copy of v4 L Room - have serial number - do not want LR5 thanks - hard drive HP lost - gone along with my software

    Moved from Photoshop forum to Lightroom forum
    Lightroom 4.4 downloads
    Win: http://www.adobe.com/support/downloads/detail.jsp?ftpID=5567
    Mac: http://www.adobe.com/support/downloads/detail.jsp?ftpID=5566

  • Question about finding whether a reference number is NOT in the database?

    Hello,
    I use the following code to test whether the reference number is in the database
    <ul><li>CURSOR cur_yellow</li></ul>
    <ul><li>IS SELECT</li></ul>
    <ul><li>REFERENCE_NO,</li></ul>
    <ul><li>COMPANY_NAME</li></ul>
    <ul><li>FROM CONSULTANTS;</li></ul>
    <ul><li>rec_yellow cur_yellow%ROWTYPE;</li></ul>
    <ul><li>BEGIN</li></ul>
    <ul><li> OPEN cur_yellow;</li></ul>
    <ul><li> LOOP</li></ul>
    <ul><li> FETCH cur_yellow INTO rec_yellow;</li></ul>
    <ul><li> EXIT WHEN cur_yellow%NOTFOUND;</li></ul>
    <ul><li> IF ref_no = rec_yellow.REFERENCE_NO</li></ul>
    <ul><li> THEN</li></ul>
    HTP.print ('<ul><li><span class="style5">The information concerning the consultant selected has been deleted from the database.</span></li></ul>');
    <ul><li> exp := 1; -- used to make code bullet proof</li></ul>
    <ul><li> END IF;</li></ul>
    <ul><li> END LOOP;</li></ul>
    <ul><li> CLOSE cur_yellow;</li></ul>
    Do you have any ideas for how to write code to test whether the reference number is NOT in the database.
    Thanks
    Doug

    Hallo,
    in general, yes, but I think , it will be better without cursor:
    declare
    v_dummy number;
    BEGIN
    EXECUTE IMMEDIATE 'select 1 from dual where
    exists (select 1 from user_indexes where index_name = : ind_name) USING ''DOUGLASMYINDEX'
    INTO v_1;
    -- something
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    END;
    Is it necessary to perform it in dynamic SQL ?
    declare
    v_dummy number;
    BEGIN
    select 1 into v_1 from dual where
    exists (select 1 from user_indexes where index_name = ''DOUGLASMYINDEX''')
    INTO v_1;
    -- something
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    END;
    Regards
    Dmytro Dekhtyaryuk

  • Online number is not showing up in caller id

    I live in the U.S. and my online number is not showing up when I call someone.  Is there a way to fix this

    unleashyourgeek wrote:
    I am constantly having problems with clients not seeing my phone number when I call. Why is this happening? Your answer here was very short and not very specific as to how to resolve this. I have been fighting this for more than 2 months now but I keep paying for a number that people can't see when I call them.
    I'm sorry I did not give an answer that met your level of specificity.  The original poster did not post the number he/she was trying to call.  This is also a worldwide forum mostly inhabited by Skype users along with some Skype employees who post from time to time.  I'm not a Skype employee, just a user who makes use of many features of Skype to avoid paying more $$$ to the telephone companies. 
    When Skype users have Online Numbers, these numbers are not automatically used as Caller ID when calling telephones from a Skype account.  This way, the Skype users hold the control over whether or not to have a working phone number show up as Caller ID. Most who have Online Numbers want them used as Caller ID, but the users - and not Skype - get that level of control.  In my opinion, that's a good thing.
    The surest way to see the current Caller ID settings for your Skype account and change them is to log into your account on the Skype web site (use the "account" link on the upper-right corner of the Skype web site).  When you log in, you will see the current settings, and the link to make changes.  If you have Online Numbers that can be used for Caller ID, you can select them.  Online Numbers in the USA and the UK are examples of the numbers that can be used as Caller ID from Skype, and numbers from Mexico and Australia can't be used as Caller ID.  You also have options to use different numbers as Caller ID for calls to telephones in those countries, and have a "default" number used for Caller ID anywhere else.  In my case, my default number for Caller ID is my US Online Number, and my UK Online Number is used as Caller ID for calls to the UK. 
    Even with these settings properly configured, there are still occasions where your number (an Online Number, or a mobile number which has gone through the verification process with two SMS messages) will not appear on the Caller ID displays of the phones you call.  This is generally outside the control of Skype.  If you are using a number that is not a "local" number in the country that you are calling, it too may not show up on the Caller ID display.  Instead of posting on the community forums, using the Support link at the top of this page may be the better way to go.  You can go through the knowledge base trying to find a solution, and end up opening a support ticket with Skype.  If you have a subscription, you may be able to go to a live chat with Skype support. 
    Patrick
    Location/Ubicacion: Arizona USA
    Time Zone/Hora Local: UTC/GMT -7
    If this message has adequately addressed your issue, please click on the “Accept as Solution” button. If you found a post useful then please "Give Kudos" at the bottom of my post, so that this information can benefit others.
    Si esto mensaje le ha ayudado, por favor haga clic en "Aceptar como solución". Si encuentra un mensaje útil, por favor "Da Kudos" al final del mensaje, por lo que esta información puede beneficiar a otros.
    I am not a Skype employee. No soy un empleado de Skype.

  • How to update 'number of notes' field in UDM_SUPERVISOR in Invoices tab

    I made program to create the notes using UDM_RSM_CREATE function module.
    it is creating notes for selected customer and invoices and shows perfect in Notes tab, but when i see on Invoices tab there is column by the Name: Number of Notes'  this is not getting updated with the counter.
    Can any one please let me know how to update the number of notes column.
    if there are 10 notes in notes tab for the particular Invoice then the Number notes column should show as '10'.
    Please ask me if it is not clear.
    Thanks,
    Maheshkumar Gattu

    Hi Mahesh,
    I AM also trying to mass upload Notes Data and Promise to Pay data using FM "UDM_RSM_CREATE" and  "FDM_P2P_CREATE" respectively from an excel file. .
    1.My query in fm UDM_RSM_CREATE is from where will i get parameter   i_rsm_guid ,as that cannt be generated from excel file user data.
    2. My second query is once i generated case_guide via FM FDM_P2P_CREATE , its a succesfull return tat means data should appear in promise to pay but that is not happening.
    3. I got a help that after successful generation of case guid from FDM_P2P_CREATE I need to use one FM for customer create contact i.e "FDM_CCT_CREATE"  then only data will appear in collection management ....but I am not the parameters of this FM.
    Can you guide me in it. If possible can you share ur logic if my requirement is same as your. Its very critical issue for project go live.
    Thanks a lot.

Maybe you are looking for