How to User IN Clause()

Any body knows how to use IN in where clause?
I am passing values to ? like 2,3,1,0
like
String pos = "2,3,0,1";
String sql_1 = " update table tab1 set counter = -1 where counter in (?)"
                OracleCallableStatement updCounter1 = ( OracleCallableStatement ) fastConn.prepareCall( sql_1 );
                updCounter1.setString(1,pos);
                updCounter1.execute();
                updCounter1.close();
            } catch (Exception e){System.out.println(" counter not update <?>" +e);}

I use IN in where clauses all the time...
There are several things wrong with what you are trying to do...
1st: CallableStatement is used to call a stored procedure, not to execute a SQL statement. To execute a SQL statement, you use a Statement or a PreparedStatement; PreparedStatement is almost always better.
http://java.sun.com/j2se/1.5.0/docs/api/java/sql/CallableStatement.html
http://java.sun.com/j2se/1.5.0/docs/api/java/sql/PreparedStatement.html
http://java.sun.com/j2se/1.5.0/docs/api/java/sql/CallableStatement.html
2nd: your SQL is wrong; either your table is named "tab1" and your SQL should be:
String sql_1 = " update tab1 set counter = -1 where counter in (?)"or your table is named either "TABLE" or "table (or maybe "Table" or taBle"), and "tab1" is a table alias that isn't doing anything effective in this statement, and your SQL should be: String sql_1 = " update \"TABLE\" set counter = -1 where counter in (?)"The quotes are necessary to use a reserved word as a table name, but they also make the name case-sensitive, so you have to exactly match the case of the name in the database; normally table names are case-insensitive in SQL statements.
3rd: when the string value "2,3,0,1" is bound to your SQL statement, it will be bound as an Oracle character datatype value; in other words, the SQL you will be attempting to execute is:
  update table tab1 set counter = -1 where counter in ('2,3,0,1')because counter is a numeric type and '2,3,0,1' is a character type, one or the other must be converted to perform the comparison; Oracle's rules in this case are that it will attempt to convert the character dataype to a single numeric value. The value '2,3,0,1' cannot be converted to any single number, so this SQl will generate an error,. Running the SQL in a command line tool such as SQL*Plus, we see:
SQL> update tab1 set counter = -1 where counter in ('2,3,0,1');
update tab1 set counter = -1 where counter in ('2,3,0,1')
ERROR at line 1:
ORA-01722: invalid numberIf you want a parameter to be treated as a number, you need to use an appropriate numeric data type and its corresponding setXXXX function, such as setInt, or setLong
(There is at least one popular database where, I am told, the driver doesn't really implement PreparedStatement but instead does string replacement within the SQL string, and what your are trying to do more or less works; Oracle is not like that at all).
4th: each parameter in a PreparedStatement or CallableStatement corresponds to exactly one data object; you cannot pass multiple numeric values and bind them to a sinle ? parameter in your SQL. In other words, this will work:
final string sql = "update table tab1 set counter = -1 where counter in (?,?,?,?)";
PreparedStatement updCounter1 = fastConn.prepareCall( sql );
updCounter1.setInt(1,2);
updCounter1.setInt(2,3);
updCounter1.setInt(3,0);
updCounter1.setInt(4,1);
updCounter1.execute();
updCounter1.close();There IS NO WAY to with Oracle to pass a single object/parameter and have it expand to a value list. (You can pass and receive arrays to stored procedures however; I've never done more than read the documentation about it though...)
5th: there is a 1,000 element limit to the number of values in a value list
6th: you don't normally need to cast your statement classes to the Oracle implementations, unless you'r going to use an Oracle-only feature of the implementation
Finally, Oracle has published quite a number of complete examples, you might take a look...
http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/index.html

Similar Messages

  • How can user specify HAVING clause in Interactive Report

    How can user specify HAVING clause in Interactive Report after making the group by selection? Under Actions/Format, the user sees just the Group By-Sort and Group By options.

    Hi ,
    Thanks for your information.
    I am new to the APEX.*i need to show Progress bar while opening the each page* then user can know some process is happening from the backside and i don't know where i need to add and call the below function.could you please provide the steps for the progress bar.
    In my application there are almost 100 pages are there so, i need to show progress bar on each page while opening .could you please provide Global function to call on each page.
    function html_url_Progress(pThis){ 
    $x_Show('AjaxLoading');
    window.setTimeout('$s("AjaxLoading",$x("AjaxLoading").innerHTML)', 100);
    //doSubmit('APPLY_CHANGES');
    redirect(pUrl);
    Regards
    Narender B

  • Can any one tell me how to use EXISTS clause inplace of IN operator.

    Hi All,
    Can any one tell me how to use EXISTS clause AND (JC.EMPL_ID, JC.EMPL_RCD) inplace of IN operator.
    SELECT COUNT (1)
    FROM SYSADM.OHR_PERS_CURR PC
    , SYSADM.OHR_JOB_CURR JC
    WHERE PC.EMPL_ID = JC.EMPL_ID
    AND (JC.EMPL_ID, JC.EMPL_RCD) in (
    SELECT HS.EMPL_ID, HS.EMPL_RCD
    FROM SYSADM.HU_SCRTY_JOB HS, ODSHR.OHR_SCRTY_USER_CFG OS
    WHERE HS.HU_SCRTY_CFG_ID = OS.HU_SCRTY_CFG_ID
    AND OS.DB_LOGIN = USER)
    Thank you.

    SELECT COUNT (1)
    FROM SYSADM.OHR_PERS_CURR PC
    , SYSADM.OHR_JOB_CURR JC
    WHERE PC.EMPL_ID = JC.EMPL_ID
    AND EXISTS (
    SELECT null
    FROM SYSADM.HU_SCRTY_JOB HS, ODSHR.OHR_SCRTY_USER_CFG OS
    WHERE HS.HU_SCRTY_CFG_ID = OS.HU_SCRTY_CFG_ID
    AND OS.DB_LOGIN = USER
    AND HS.EMPL_ID = JS.EMPL_ID AND HS.EMPL_RCD = JC.EMPL_RCD)
    But why ?
    Rgds.

  • How many users can you have on one account ?

    Hi,
    I have just created a ID with Adobe Reader for a group to use files stored in cloud. I would like to know how many users can access the account at one time via, mobile devices, ipad, desktops ?

    I don't know if there is a limit; you do mean the free https://cloud.acrobat.com/ ?
    I will move your post to the Acrobat.com forum, where someone hopefully can give you a definitive answer.

  • How to know how many users uses Report Designer?

    Dear Experts,
    Somebody knows if it's possible to know how many users have made look ups in Report Designer on one period or how many modifications?
    Thanks in advance.

    Hi,
    If the cube is checked for Statistics, there is a option settings for BI Statistics under tools, then all the user related info is stored in Techincal Content Cubes. Based on TCT(technical Content Cubes), you need to create a report based on the requirement. From then we can know user log info for the particular queries.
    Hope this helped you
    Thanks
    PT

  • How far will the extreme reach and how many users can be on there at the same time?

    How far will the airport extreme reach and how many users can be on there at the same time?

    Last question first, since that is the easy one......approximately 50 (fifty) users for wireless depending on how active each user might be.
    The first question is much more difficult, as distance is not really the issue with wireless.....obstructions are the issue.
    A wireless signal can easily travel 300 feet or more with no obstructions in the signal path.
    But, a typical wall of sheetrock or wallboard in a home will absorb....on average....15-20% of the wireless signal. Brick or adobe will obviously absorb much more. A ceiling....because it is thicker....will absorb about 25-35% of the signal.
    So, if the wireless signal must pass through several walls and a ceiling, there won't be much, if any, of the signal left....even though the distance that the signal travels is not great...for example, 20-25 feet.
    Other wireless networks around you at the neighbors can also affect the relative strength of the wireless signal.
    The bottom line....locate the AirPort Extreme where wireless devices will receive a signal with the least amount of obstructions in the signal path. Your actual performance cannot be predicted in advance. You will not know how well the AirPort Extreme works for you until you try it out in your home.
    If you find that the signal does not reach as far as needed,  you will need to add additional "extenders", like an AirPort Express to provide more signal coverage.

  • How many users can 1 Xserve support?

    I have one Xserve (10.5.2, 2x3GHz, 5GB RAM, 1.34TB RAID 5) that I want to support the following services for my SMB:
    DNS, DHCP
    AFP, NFS, SMB
    Open Directory
    Print
    Software Update
    I also want to have mobile sync'd network home folders, but only for ~/Documents and iCals and Address Books (I don't want everyone's MP3s or family photos).
    I occasionally will use NetBoot/NetInstall, but only 1-2 users at once.
    I am getting ready to migrate my company to OpenDirectory and 10.5.2 for all users and was hoping someone here might be able to tell me how many users I can reasonably support with one Xserve.
    Also, is it a bad idea to have everyone using "mobile" accounts? It seems like it would be less strain on the server to have the occasional sync from users than everyone reading & writing all the time. Also, if anything happened, there would be a local copy and a remote copy of any files.
    Thanks.

    Rosemarie,
    BeehiveOnline currently supports 95,000 users and we have groups on the system as large as 10,000, that is probably about as big as we want to go - remember collaborating with 10,000 users is not an effective way of working - maybe a more open way of delivering content may be more appropriate. Given that the only issues we have with very large groups is the time it takes to run and the email traffic it generates as the large group are processed.
    So it is possible to host 10,000 in a group but we need to be warned in advance and work with you to minimise the impact as the group is set up.
    Phil

  • How many Users online at any one time?

    Is there any better (/more accurate) way of determining how many users are using Planning at any one time then "Administration >Application>Statistics"?
    I've been using the Statistics up until now but it's hardly fit for purpose. The timings look dubious and the same users can be there 20+ times in the same list.
    It's not a deal breaker, but would be nice to see if anyone else had any hints on this.
    Regards
    Ed

    Even after a reset the numbers look very weird. Apparently it's been 6 weeks since I last accessed Planning... I should be fired!
    Slightly off topic: My Supporting Detail Detection Cache Usage is at 100%, am I right in thinking I should DECREASE the cache size in the Application Properties as per the Documentation (http://download.oracle.com/docs/cd/E17236_01/epm.1112/hp_admin.pdf - P83)?
    Sounds wrong to me.
    Any ideas anyone?

  • How many users for remote connection can I  create, from support SAP

    Dear all
    I have a doubt with how many users can be created in my system ERP 6.0 for the remote connection, for the error product  messages on the marketplace SAP,without this counts as user license.
    I have not found any notes or documents from SAP to explain this.
    I appreciate your help.
    Best Regards,
    Erika

    Ok...I will reply to myself. I can use more than 10 simultaneous connection, using vnc.

  • How many users are there of Logic?

    does anyone know where I can find out how many users there are globally of Logic Pro. I'm doing an assignment on this and I can find sales figures for DAW software anywhere....

    You can or can't find sales figures?
    It is also rumoured that there are many non legitimate users out there too. Please note however, I am not one of those.
    Anyway, what is the assignment for? ie What's the gist, requirements and subject matter? Just interested.
    Regards,
    Matt

  • How many users does HFM support?

    Hi,
    how many users does HFM support(Maximum)? and why we are choose HFM compare to Hyperion enterprise?
    thanks
    Edited by: user10919054 on May 18, 2009 3:07 AM

    There is no limit, as long as you pay for the licenses and make sure you have a robust system to support user connectivity and demand.
    Hyperion Enterprise is the previous Consolidation tool most commonly used by many companies. Think of HFM as the "New Generation"....

  • How many users in UME

    Hi,
    Does anyone have any idea on how many users can be stored in the UME engine without affacting performance?
    We have a current senario with about 200 portal useres, but are going to use the portal with more users in the future.
    The users are stored in UME and mapped to the backendsystem (so basiclly stored to places)
    I know it is better to hav a own reposotory I was just wondering what kind experinse you have with many users in the UME.
    Thanks

    Hi,
    10,000 will not matter.
    In our landscape we have 60000 user access the portal.
    Only you have to keep in mind , when there is good number of user in system , you have to properly tune you system.
    Your hardware sizeing should be upto in addition to that.
    Can you tell me how many server nodes are there in you landscape or how many application servers are there.
    Thanks,
    Anil

  • How many users can I import at one time?

    Is there a limit on how many users I can import at one time?
    Also, how about other record types (Lead, Opportunity, Contacts ...etc.) Is there a limit on these also?
    Where in the documentation that I can find info for this please?
    I'm using CRMOD Release 18
    Thanks

    Account
    30,000
    Account Team
    50,000
    Appointment
    30,000
    Appointment Contact
    50,000
    Appointment User
    50,000
    Asset
    80,000
    Campaign
    50,000
    Contact (Admin)
    30,000
    Contact (Personal)
    2,000
    Contact Role
    50,000
    Contact Team
    50,000
    Lead
    30,000
    Notes
    50,000
    Opportunity
    30,000
    Opportunity Product
    80,000
    Opportunity Team
    50,000
    Portfolio
    30,000
    Product
    80,000
    Service Request
    30,000
    Solution
    50,000
    Task
    30,000
    Task Contact
    50,000
    Task User
    50,000
    User
    500
    Campaign Recipient
    50,000
    Custom Objects
    30,000
    Dealer
    80,000
    Vehicle
    80,000

  • How to see how many users are working on a Dynpro application?

    Hello,
    Is it possible to see somwhere at the portal or on the WAS how many users are currently working with my Web Dynpro application?

    Hi Roy,
    I know it isn' exactly what you want but if you got to:-
    System Administration->Support->Web Dynpro Test Tools->User Management
    you can at least see the users currently running Web Dynpro applications (I think!)
    At least its a start!
    Cheers,
    Gareth.

  • How many users can connect to a shared drive on a non-server workstation?

    How many users can connect to a shared drive on a non-server workstation? We're waiting for our server to arrive and in the interum we're using a Pegasus 2 R6 attached to an iMac running Mavericks as our fileserver. It's been sketchy, the connection to the server being dropped once in a while or the inability to mount the drive after a week of success. The Pegasus we're using now will be attached to a server once it arrives. For now I need to figure what's coausing trouble before I commit to this being our main storage as planned. The data is backed up every night so I'm not worried, its the usability issues. 5-7 people are mounting this drive and opening/saving at the same time. Is there a limit to Maverick's fileserving ability that may be causing this? Understandable if so.

    The file server in the client version of OS X has a default limit of 10 simultaneous connections. That limit can be raised by installing OS X Server, or lowered by setting a hidden preference. Assuming you've done neither, you may be able to solve the problem temporarily by stopping and restarting file sharing in the Sharing preference pane, or permanently by setting another hidden preference on the server to break idle connections quickly.
    defaults write /Library/Preferences/com.apple.AppleFileServer idleDisconnectOnOff -bool YES
    Stop and restart file sharing. To reverse the change, run this command in the same way:
    defaults write /Library/Preferences/com.apple.AppleFileServer idleDisconnectOnOff -bool NO
    Credit for this solution to ASC member suter:
    this file server will not allow any additional users to log on

Maybe you are looking for

  • Version 3.1 fault - ORA-06502 error when creating SQL Report Region/Page

    I usually perfect my query in SQL*PLUS before I create a new report region. Consequently, I copy the code into the region wizard to create the new page. However, since we have upgraded to Version 3.1, virtually every report I have tried to create has

  • Router for cable AND DSL at the same time?

    Can I get cable and DSL service and buy a router that will run both at the same time? I'm looking at the Linksys RV016, RV042 and RV082 routers; and the D-Link DI-LB604 Load Balancing Router. It looks like they'll do this but the webpages don't say t

  • HP Officejet Pro L7580 All-In-One printer with Windows 8

    I have the HP Officejet Pro L7580 All-In-One printer and want to use it with my new laptop that has Windows 8, but it won't accept the Starter CD (Windows 2000, XP, Vista).  Where can I get a free download to use with Windows 8?  I can print, but cur

  • Flash 10.1 Restarts all the time in Facebook games

    Win XP Pro Sp 3 256MB Mem Problum with IE7 So I upgraded to IE 8 and same problum New Windows Install (4 Months) When I use a progrem/game that used Flash. the windoe will close all of sudden sometimes I can play for a ewhile and some times it happen

  • How to install Stateful Session Bean installed in a OAS9i

    Hi Techies: I am a newbie to work in Oracle Application Server 9i.I have developed a simple bean in Oracle JDeveloper 9i. I have also developed the EAR file and wgile deploying the EAR file in the OAS 9i. I am getting the following error while deploy