Using SQL "IN" command with PreparedStatements

SELECT *, OTODPT FROM OEORDer
where OTODPT IN ('RAD','LAB')
Can you do the following with the above code:
stmt_ = jdbcConnection_.prepareStatement(SELECT *, OTODPT FROM OEORDer where OTODPT IN (?) );
if so what needs to be set for the PreparedStatement?
I have tried stmt_.setString(1, "'RAD','LAB'");
but noting was returned.

I noticed in another thread the jschell had answered your question for another poster. Here is what he said:
String str="select lastname from account where userid
in ( ? )";You can't do that.
The only solution is to create the SQL String dynamically yourself. You can either create it using the correct number of '?' to fill it, or just create it with the actual data.
>
Replace x with 'Tom', 'Steve' or ..
"Tom, Steve"And the reason it doesn't work is because it ends up looking like this
...where userid in ( 'Tom, Steve')

Similar Messages

  • How to numberformat when using sql:query alogn with c:forEach JSTL tags

    Is there anyway to format the numeric values returned from the database when using <sql:query> alogn with <c:forEach> tags
    Here is my jsp code
    <sql:query..../>
    <c:forEach var="row" items="${queryResults.rows}">
    <tr>
    <td><c:out value="${row.COL1}" /></td>
    <td><c:out value="${row.COL2}" /></td>
    </tr>
    </c:forEach>
    Col1 values are numeric without any formats Eg: 1000, 10000, 1000000 etc.
    how can i format them to 1,000 , 10,1000 , 100,000 etc

    It is polite to mention what your answer was. These posts are not just here for you to ask questions, but to be used as a resource for other people to find answers. Saying "I solved it" with no details helps noone.
    I presume you discovered the JSTL <fmt:formatNumber> tag?

  • Using SQL Server credentials with Secure Store Target Application for Data Connection in Dashboard Designer

    [Using SharePoint 2013 Enterprise SP1]
    I would like to use SQL Server credentials in a Secure Store Target Application, and
    this page makes it look like it's possible but when I attempt to use the new Target Application ID as authentication for a Data Connection in Dashboard Designer, I get a generic "Unable to access data source" with no error logged in SQL Server
    logs.
    I am able to use a Target Application with AD credentials to access the SQL db without a problem. Suggestions?

    Hi,
    1. Make sure that the credential is set to
    Secure Store Target Application. Navigate to the Central Administration. Click on the
    Application Management. Click on the Manage Service Applications. Click on the
    Secure Store Service Application. Select the application ID and from the ECB menu click on the
    Set Credentials. Enter the Credential Owner, Windows User Name and the
    Windows Password.
    2. Make sure that in the Dashboard Designer “Use a stored account” is selected in the “Authentication” and the proper application ID is mentioned.
    Please refer to the link below for more information:
    http://www.c-sharpcorner.com/Blogs/14527/unable-to-access-data-source-the-secure-store-target-applic.aspx
    Regards,
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected] .
    Rebecca Tu
    TechNet Community Support

  • Using 'defaults delete' command with com.apple.dock

    I have been using the "defaults" command in my scripts to add an icon to a user's dock after a new application has been installed. But now, I'm having trouble trying to figure out how to remove an icon from the dock using the command line. For adding an icon, I use:
    defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict>
    <key>_CFURLString</key><string>/Applications/NewApp/Program.app
    </string><key>_CFURLStringType</key><integer>0</integer>
    </dict></dict></dict>'
    (take out all the carriage returns and spaces. I had to put them in here for the line to show properly on the post)
    This works great for adding an icon. But, I cannot seem to write something similar using "defaults delete"
    Any help is appreciated.
    Thanks,
    -Steve
    PowerMac G5   Mac OS X (10.4.7)  

    Hi Steve,
       If it froze then the code isn't robust against problems. In this case the problem is the web. The command has four spaces in a row in two of the matches. However, the browser smashes that down into a single space. I never understood that aspect of HTML but I know about it and should have considered it. I will replace the spaces with capital Xs. If you replace the Xs with regular spaces, the command should work:
    defaults write com.apple.dock persistent-apps "$( defaults read com.apple.dock persistent-apps | awk 'BEGIN{ ARRAY = "("; ELEM = "" } /^XXXX{/{ while ( $0 !~ /^XXXX}/ ) { if ( ELEM == "" ){ ELEM = $0 } else { ELEM = ELEM "\n" $0 } if ( $0 ~ "_CFURLString\"" && $0 !~ /zzzz/ ){ FOUND = "true" } getline } ELEM = ELEM "\n" $0; if ( FOUND == "true" ){ ARRAY = ARRAY "\n" ELEM }; FOUND = "false"; ELEM = "" } END{ sub( /,[^\n]*$/, "", ARRAY); print ARRAY; print }' )"
    In some sense that is poor coding but in the default syntax of the "defaults" command, the only way to determine depth is by how far something is indented. It would have been far more robust to actually count the number of opening parentheses and keep track of the depth but that would have been more complex to code. If I have time, I'll look into changing that.
       I assume that the reason the command hung is that it went into an infinite loop. I've also added a carat, '^', in front of the first group of four spaces that will keep that from happening. When typed correctly the command works without it but now it will fail without going into an infinite loop.
    Gary
    ~~~~
       United Nations, New York, December 25. The peace and joy of the Christmas season was marred by a proclamation of a general strike of all the military forces of the world. Panic reigns in the hearts of all the patriots of every persuasion. Meanwhile, fears of universal disaster sank to an all-time low over the world.
          -- Isaac Asimov

  • 11g: can connet using SQL*PLUS, not with TOAD

    Hi
    I run into a problem with TOAD. I can't connect with my 11g database using TOAD. I don't get any messages it just gives me a little waiticon for a split second and then nothing happens. I can however connect to my 10g database using TOAD. Using SQL*Plus I can connect to both.
    I use TOAD 8.6. Do I need a newer version maybe??...

    I can connect like:
    hr/pw@xe
    or
    hr/pw@O11R1
    or directly, no problem. I can connect from SQLplus to both databases any way I want

  • Use sql function decode with Zend code

    Hi,
    I need to use sql function DECODE() in a query for PHP Code. This query works well in sql*plus but PHP returns
    the following error message:
    Parse error: syntax error, unexpected T_STRING in C:\Program Files\Zend\Apache2\htdocs\Compta\compta2.php on line 16
    the query is :
    $query =
    'select substr(c.NUM,1 ,2) Compte ,
    c.designation , a.Periode
    ,decode(substr(c.NUM,1 ,1), '1',1, '2',1,'3',1,-1) cp_type ,
    sum(credit) - sum(debit) Montant
    from ecritures a, clients b, compte c
    where
    b.NUM (+) =a.NUM
    and a.DATEECRITURE between to_date(:debut, \'dd/mm/yy\') and to_date(:fin, \'dd/mm/yy\')
    and substr(a.num,1,2) =c.num
    group by substr(c.NUM,1 ,1), substr(c.NUM,1,2) , c.designation ,a.periode
    order by compte ';
    Can any one help me ???
    Thanks by advance
    nb: Iuse Zend 2.0

    Hi,
    You need to escape single quote mark:
    decode(substr(c.NUM,1 ,1), \'1\',1, \'2\',1,\'3\',1,-1) cp_type ,
    the same way you did for to_date:
    to_date(:debut, \'dd/mm/yy\')
    Regards,
    Paweł

  • Using the IN command with parameters

    I am using .Net with the Oracle 10G client software to connect to a 10G database. I have a package that contains a stored procedure where I need to pass in multiple values to utilize the IN command, but I keep getting a cryptic Oracle error. Basically this is the scenario..
    SELECT * FROM [Table] WHERE ID IN(P_PARAMETER);
    Through my .Net code, I set P_PARAMETER equal to something like "25,31,36,48" without the double quotes. I also tried surrounding each number with single quotes and it still bombed out. Is this valid to do? If not, what are my options since I need to use this scenario (the numbers aren't known ahead of time)?

    may be you are looking for this, you have to use dynamic sql,
    i am using ref cursor to display the data, basically the inlist you are passing is comma seprated as under
    SQL> var c refcursor;
    SQL> var NO VARCHAR2(200);
    SQL>
    ---- this is the in list with comma seprated
    SQL> EXECUTE :NO:='10,20';
    PL/SQL procedure successfully completed.
    -- i am paasing that in list here to procedure
    SQL> CREATE OR REPLACE PROCEDURE test_in (pdno IN VARCHAR2, p_cursor OUT sys_refcursor)
      2  IS
      3       st                            VARCHAR2 (200);
      4       vename                        VARCHAR2 (20);
      5  BEGIN
      6       st         := 'SELECT empno,ename  FROM emp  WHERE dno in ('||pdno||')';
      7       DBMS_OUTPUT.PUT_LINE (pdno);
      8       DBMS_OUTPUT.PUT_LINE (st);
      9       OPEN p_cursor FOR st ;
    10  END test_in;
    11  /
    Procedure created.
    -- calling the procedure
    SQL> EXECUTE  test_in (:NO,:c);
    10,20
    --- this how the statement will look like
    SELECT empno,ename  FROM emp  WHERE dno in (10,20)
    PL/SQL procedure successfully completed.
    printing the out put
    SQL> print :c;
         EMPNO ENAME
          7369 SMITH
          7566 JONES
          7782 CLARK
          7788 SCOTT
          7839 KING
          7876 ADAMS
          7902 FORD
          7934 MILLER
    8 rows selected.
    Elapsed: 00:00:00.00
    SQL> added comment
    Message was edited by:
    devmiral

  • How can I use SQL TOOLKIT concurrently with Database Connectivity ?

    I have installed LabVIEW 6.1 with the Database Connectivity Toolkit and the SQL Compatibility Toolkit (e.g. _SQL folder). I am trying to make the transition from the SQL Toolkit VIs to the Database Connectivity toolkits, but for compatability with existing systems I would like to be able to run the two sets of VIs concurrently (but not in the same app).
    When I read into 6.1 a connection VI that I wrote with LabVIEW 6.0 and the SQL toolkit the connection reference type gets changed from a number to type connection (see attachments) . Does compatbility mean that my SQL toolkit VIs are converted to a form compatible with the new ADO ?
    Can I use the SQL Toolkit VIs or the Database connectivit
    y VIs in the same installation of 6.1 ?
    Can I have the SQL Toolkit VIs appear on the functions pallette and function as they did when only the SQL toolkit was installed ?
    Attachments:
    CNNCT.vi ‏20 KB
    CNNCT.vi ‏22 KB

    In response to your #2 below:
    Actually it is possible to have the old SQL Toolkit and new Database
    connectivity in the same installation of LabVIEW. I have only tried it on
    6i, but don't see why it wouldn't work on 6.1. The trick is not to install
    the SQL toolkit compatabitily VI's. The old SQL toolkit uses the Intersolve
    dll through ODBC while the new Database connectivity uses ADO so it is
    possible to use both methods not only in the same LabVIEW install, but it
    the same running application. It has been a while since I originally did
    this, so I am posting only to mention that it is possible and not exactly
    how to do it. If anyone is interested in more details just respond.
    Brian
    "Jeff B" wrote in message
    news:[email protected]...
    > First, direct answers to your direct questions:
    >
    > 1. Does compatbility mean that my SQL toolkit VIs are converted to a
    > form compatible with the new ADO ?
    >
    > Yes
    >
    > 2. Can I use the SQL Toolkit VIs or the Database connectivity VIs in
    > the same installation of 6.1 ?
    >
    > No
    >
    > 3. Can I have the SQL Toolkit VIs appear on the functions pallette
    > and function as they did when only the SQL toolkit was installed ?
    >
    > No
    >
    >
    > Now an elaboration:
    >
    > Having the old SQL Toolkit and the new Database Connectivity Toolset
    > installed on the same version of LabVIEW on the same computer is not
    > supported.
    >
    > Once you install the Database Connectivity Toolset, any VIs written
    > with the SQL Toolkit will run, but with the ADO layer, as you
    > suspected.
    >
    > Internally, the only way we can have both the SQL Toolkit and the
    > Database Connectivity Toolset installed on the same computer for
    > troubleshooting customer issues is to have them installed on different
    > versions of LabVIEW. I, for example, have LabVIEW 5.1.2, 6.0.3, and
    > 6.1 all installed on my computer, and I have the SQL Toolkit install
    > on LabVIEW 5.1.2, and the Database Connectivity Toolset installed on
    > LabVIEW 6.0.3. In this configuration I can still run SQL Toolkit VIs
    > independent of the Database Connectivity Toolset if I open and run
    > them in LabVIEW 5.1.2.

  • Using SQL reporting services with java

    how can i use Microsoft SQL Server reporting services with java? The idea is that we create the reports using Microsoft SQL Server reporting services. Then we have our web application where user will select one of those report, pass 0 or more arguments and then we will show the report.

    nobody is using Microsoft SQL Server reporting
    services with java?Found this in 0.01 seconds with Google http://www.javaworld.com/javaworld/jw-01-2005/jw-0110-sqlrs.html
    Handy tool that Google.

  • Using SQL in VC++ with ADO ( in Oracle9i)

    Hi ! i am a newcomer .
    Are there any document about this ?
    I want manipulate the Oracle databse with SQL statements
    in VC++6.0 , there are LOB fields
    I use ADODB
    With VB6.0 is OK but in VC++ i don't know whatto do
    Thaks all
    email : [email protected]

    If you have a support contract, there is a fair amount of C++ ADO sample code available on Metalink. Otherwise, there are tutorials available on the internet... googling for "ADO C++ sample code" got me to one tutorial http://www.developerfusion.com/show/4033/ -- there are certainly others out there.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Emailbody using SQL: Align Table with Headers

    I have a requirement, Where I need to align header and table contents , as a part EMAIL body in HTML format. I'm getting the resultset from a table.
    Here is the output
    Rows in these Columns have following maximum length:
    Table Name :Maximum length of table name is 40.
    Building: Maximum length is 15
    CreatedDate: Maximum length is 25
    I would appreciate it if someone can help me on this.
    Thanks in advance.
    ZK

    Hi,
    The Integration Services SendMail task only supports mail messages in plain text format. However you can easily send HTML mail messages by using the Script task and the mail capabilities of the .NET Framework.
    Please refer to the following articles about this topic:
    Sending an HTML Mail Message with the Script Task:
    http://technet.microsoft.com/en-us/library/ms403365(v=sql.90).aspx
    SSIS - Data Table displayed in Script HTML Email Body:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/bc395a54-da68-4041-b142-5108a5ad250c/ssis-data-table-displayed-in-script-html-email-body?forum=sqlintegrationservices
    If you have any more questions regarding SSIS, I would suggest you open a new thread in SSIS forum for better support.
    If you have any feedback on our support, please click
    here.
    Elvis Long
    TechNet Community Support

  • Problems using 488.2 commands with Agilent 82357 interface

    Hi, I need to send a large file to an instrument in chunks using the 488.2 commands sendsetup and senddatabytes. When I try to use these commands I just get an error saying 'NI-488: Error connecting to driver or device'. The interface works fine using visa. I’ve tried the obvious in checking that the bus address is correct and I believe it to be.
    Anybody know what I may be doing wrong or if its possible to do it another way? I’m starting to wonder if its an issue with it being a non NI interface.
    Thanks

    Hi,
      We have done trade-ins in the past with 3rd party hardware, and this may be an easy solution for you since we do have a USB-GPIB interface available that does Standard and HS gpib (you didn't say if you were using the A or B variant of the Agilent 82357.
    http://sine.ni.com/nips/cds/view/p/lang/en/nid/201586
    I'd suggest contacting your local sales office (+44 1635 572400 for the UK) to find out if this is acheivable in your case, or to arrange a loan to see if that in fact fixes the issue and makes the option more practical.
    Thanks
    Sacha Emery
    National Instruments (UK)
    // it takes almost no time to rate an answer

  • SQL In command with parameter

    Hi ,
    When i tried to execute this query it returns empty data set.did i miss something or is it not allowed to use ?
    SQL:
    String sql=" select * from customer where customerId in( ?)";
    objConnection = super.getConnection();
    stmt1 = objConnection.prepareStatement(sql);
    stmt1.setString(1, id); //here id format will be ('100','102'......)
    resultSet = stmt1.executeQuery();
    Thanks in advance.

    You mean something like...
    SQL> ed
    Wrote file afiedt.buf
      1  select *
      2  from emp
      3  where ename in (
      4    with t as (select '&input_string' as txt from dual)
      5    select REGEXP_SUBSTR (txt, '[^,]+', 1, level)
      6    from t
      7    connect by level <= length(regexp_replace(txt,'[^,]*'))+1
      8*   )
    SQL> /
    Enter value for input_string: SCOTT,JAMES
    old   4:   with t as (select '&input_string' as txt from dual)
    new   4:   with t as (select 'SCOTT,JAMES' as txt from dual)
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
          7788 SCOTT      ANALYST         7566 19-04-1987 00:00:00       3000                    20
          7900 JAMES      CLERK           7698 03-12-1981 00:00:00        950                    30
    SQL>

  • How to use SQL filtercondition 'Start with' and 'connect by' in ADF's LOV?

    Hello every!
    I can not use 'Start with' and 'connect by' with parameter in creating ADF's LOV?
    How could I do with it?
    Alex

    assuming you are using adf 11g,
    You need to use View Criteria with the View Object attribute that has a LOV model.
    Follow this, to get some idea http://andrejusb.blogspot.com/2008/12/cascading-lovs-in-oracle-adf-11g-update.html
    hope this helps,

  • SPEL - Using SQL queries along with Function security

    Hi,
    I have tried the basic features of SPEL using function security and VO attribute. I would like to know if there is a way where I can write SQL or PLSQL blocks and set SPEL.
    I am trying to relate the functionality of Oracle Forms, where we can personalize and perform actions depending on the SQL statements.
    Could you please help.
    Regards,
    BM

    Hi Sushant,
    Thanks for the reply. I am aware of extending a view object and setting SPEL. I want a method where I can achieve SPEL without extending any BC4J object.
    Regards,
    BM

Maybe you are looking for

  • Error when I try to run a form

    Hi, I created a table-based form, but I get a error when I try to run it (CTRL+R): java.lang.ClassNotFoundException: oracle.forms.engine.Main How can I fix it? Thanks Savio Barros

  • Where to locate video clips in FCP

    Hello I have a setup where I have a my main boot disk and 2 300gig raid setup. I run all my apps off the boot and data saved on the 2, pictures, movies, etc form FCP, I photo, etc. So I had to change out the boot disk as it died. I am all restored bu

  • If I delete files from my computer, do they remain on the time capsule and how do I access them?

    If I delete files from my computer's hard drive do they remain on time capsule? Where? How do I access them?

  • Debug in Extractor Checker

    One of my infoPackage load to PSA failed.  I found the error is in the source system user exit.  There are over 4500 records in this PSA request.  How do I find out which records is having the error?  According to the system log it error out at the f

  • Iphoto user permission repair

    I recently shared my iphoto library with another user on my Macbook.  Now every time either one of us opens iphoto (when it is closed in the other's account) it asks to "repair user permission".  Do we have to do this each time now?  Also, this requi