Why can't I select or update the Record using the PreparedStatement?

the DB is oracle9i,here is the test table
test
id number;
name char(10);
intro char(10);
I have insert a record in the table.
Now I will select or update the record by using the PreparedStatement here is my code:
sqlStr = "update test set intro = ? where name =?";
PreparedStatement stmt = conn.prepareStatement(sqlStr);
stmt.setString(1,"my name is irixwang");
stmt.setString(2,"irixwang");
int is = stmt.executeUpdate();
if (is >=1 )
System.out.println("ok");
It will not work ,but where I change the update condiction as followed:
sqlStr = "update test set intro = ? where id =?";
PreparedStatement stmt = conn.prepareStatement(sqlStr);
stmt.setString(1,"my name is irixwang");
stmt.setInt(2,100);
int is = stmt.executeUpdate();
It works well,why?
please help me!thk!!!!

I doubt it works "well" in either case since you are inserting a string that is longer than 10 characters into a field that only holds 10 characters. But to your question....
A char data type holds a fixed number of characters - in your case 10.
Because it holds 10 characters it will never hold 9, regardless of what you think is in the field it will always have 10 characters in it. The value you are using for query for name is 9 characters. Since 9 characters, regardless of content, will never be equal to 10 characters there is no way that it will update.
So your choice is to either use a varchar, which holds a variable number of characters, or to always use 10 characters for your query (pad it with spaces.)

Similar Messages

  • Why can't I print to a Zebra 2746e using the report tool kit?

    I have read on here how peoople have printed barcodes from LV by sending commands directly to a zebra printer. I am using LV8.2.1 on a windows xp computer. I am sending EPL2 messages to the printer using the report tool kit, but all I get is a couple of line feeds. If I send the commands from a command prompt by coping a test file to the printer port it prints fine. Any thoughts. I have attached my program.
    Attachments:
    zebra tester.vi ‏22 KB

    I tried your code against my printer and it works as advertised. Can you print to other printers with it?
    By the way, when assembling a string you should use the Format Into String function instead of a string concatenator with a bunch of inputs. It takes up less room and is easier to interpret when troubleshooting.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Why can't I select Design as a product in the Adobe Download Assistant?

    when i click select product i can not find design only photography pdf abd video

    Edude118118 the Design category is no longer available in the Adobe Download Assistant because there is no trials available in this category.  Which Adobe software title are you wishing to download and evaluate?
    If you are looking for the current version of our Design products such as InDesign CC then you can try a free trial membership to the Adobe Creative Cloud.  You can find more details at http://www.adobe.com/products/creativecloud.html?promoid=JQPEQ.

  • In Elements 12 why can't I suddenly not reposition layers without using the layer panel?

    In Elements 12 I have always been able to drag photos from the bin onto a background and easily move them or alter them simply by clicking on those photo/slayers while working on the same background without using the layer panel.  A couple days ago I suddenly have to show the layer panel and click on that particular layer in the panel before I am able to move, alter, or delete a particular layer. Also, every time I open a new image or blank file to use as a background, I am suddenly working with a locked background which I don't want, and the directions to un-lock don't seem to work, if that has something to do with it.  I didn't change any settings that I know of.

    For editing purposes, the thrust of the program is to work in layers, and to do that it is necessary to have the layers palette in view so that the appropriate layer can be made the active layer.
    The background layer is locked by default. You can probably drag the padlock to the trash can, or, do your work on a duplicate layer which will come in unlocked.
    Try dragging photos from the layers palette to the work area, not up from the photobin to the work area.
    Also, go to Edit>Preferences>General and be sure that "Allow Floating Documents in Full Edit Mode" is checked.

  • Why can I not select multiple items in Muse using Shift Click after installing update?

    I am trying to select multiple items on a Muse page by holding shift and clicking each items. This has been pretty much my standard method across Adobe products but after updating Muse it will no longer let me do this. Am I missing something or did this method change with the update?

    It seems to be happening mostly for Hotmail account.  I just rebooted and tested two accounts.  Only in Hotmail now.

  • Why can't I select and drag files around in the preview area?

    Out of nowhere.  I have had no issues and now it is pretty much unusable.  I thought maybe it was a bug so I uninstalled/reinstalled.,  There was an update when I went to install it the second time.  I thought the update would help but there's no change.  Help please!

    Hi Anni,
    Out of nowhere.  I have had no issues and now it is pretty much unusable.  I thought maybe it was a bug so I uninstalled/reinstalled.,  There was an update when I went to install it the second time.  I thought the update would help but there's no change.  Help please!
    Do you have the Google Chrome "Pushbullet" extension installed on your computer? If so, uninstall it.
    Thanks,
    Kevin

  • [Android]why can't "text reflow" be fixed instead of using the unreliable broken "text inflation"?

    text inflation as a desktop-to-mobile-view conversion doesn't work, and can never be fixed.
    it will always either fail to make important parts of websites readable, or completely unhinge them.
    opera mini, opera mobile(now classic) and opera for android show how well "text reflow" works for desktop pages on mobile devices.
    before the opera mobile EOL I never needed mobile versions of pages.
    firefox for android already has a text reflow feature, but it is hidden away and unusable because of 2 easily fixable problems.
    1. "text inflation", it's completely unnecessary to require enlarged text in order to reflow but with this feature disabled(text to smallest size) there is no reflow.
    2. "fixed zoom", currently double-tap zooming will always put the text fullscreen(which on a desktop layout is still too small)
    a "fixed zoom" option that always zooms a set % regardless of where you double-tap should allow zooming in to a level where text is readable and should force "text reflow" to reflow text to screen-width.
    so why are we still stuck with either messy or unreadable text on desktop pages?

    you seem to have missed the point of my post.
    firefox has 2 methods to make desktop pages readable on phones, "text reflow" and "text inflation".
    text reflow is disabled by default and doesn't work properly because of a few unchangeable settings, even though it is proven to be a very effective and reliable method to make desktop pages work on phones by opera's browsers.
    and text inflation is broken because it can never accurately determine what can and can't be inflated.
    and my question is why we're still stuck with using text inflation when text reflow is a much better option?

  • Updating a record using pay element using the API (Almost Done)

    Hi Everyone,
    I have a question about updating a record using the PAY_ELEMENT_ENTRY_API.update_element_entry
    I have process that doesn't error out, but its doesn't seem to update the record. So my question is, is the query below the correct way to get the element name and object version number when using this API? If not, what do I need to do?
    BEGIN
    SELECT MAX(pee.element_entry_id)
    INTO x_element_id_mgr
    FROM pay_element_types_f pet,
    pay_element_links_f pel,
    pay_element_entries_f pee,
    per_all_assignments_f paaf,
    per_all_people_f papf
    WHERE pee.element_link_id = pel.element_link_id
    AND pel.element_type_id = pet.element_type_id
    AND paaf.assignment_id = pee.assignment_id
    AND papf.person_id = paaf.person_id
    AND pet.element_name = 'Mgr Rec Pct'
    AND sysdate BETWEEN pee.effective_start_date AND pee.effective_end_date
    AND sysdate BETWEEN pel.effective_start_date AND pel.effective_end_date
    AND sysdate BETWEEN pet.effective_start_date AND pet.effective_end_date
    AND sysdate BETWEEN paaf.effective_start_date AND paaf.effective_end_date
    AND sysdate BETWEEN papf.effective_start_date AND papf.effective_end_date
    AND paaf.assignment_id = c_staging.assignment_id
    AND papf.person_id = c_staging.person_id;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    --ROLLBACK TO s1;
    v_error_message := 'For employee number '||c_staging.employee_number||' No data found for element name Mgr Rec Pct' || SUBSTR(sqlerrm, 1, 200);
    DBMS_OUTPUT.PUT_LINE('Error occurred : ' || v_error_message);
    WHEN OTHERS THEN
    --ROLLBACK TO s1;
    v_error_message := 'For employee number '||c_staging.employee_number||' Error found for element name Mgr Rec Pct' || SUBSTR(sqlerrm, 1, 200);
    DBMS_OUTPUT.PUT_LINE('Error occurred : ' || v_error_message);
    END;
    --- Get OVN
    BEGIN
    SELECT MAX(Object_version_number)
    INTO x_ele_object_version_number
    FROM pay_element_entries_f
    WHERE element_entry_id = x_element_id_mgr;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    v_error_message := 'For employee number '||c_staging.employee_number||' Error in getting the OVN for Mgr Rec Pct ' || SUBSTR(sqlerrm, 1, 200);
    DBMS_OUTPUT.PUT_LINE('Error occurred : ' || v_error_message);
    WHEN OTHERS THEN
    v_error_message := 'For employee number '||c_staging.employee_number||' Error in getting the OVN for Mgr Rec Pct' || SUBSTR(sqlerrm, 1, 200);
    DBMS_OUTPUT.PUT_LINE('Error occurred : ' || v_error_message);
    END;

    Your SQL isn't bad, although you're including loads of tables you don't need to so it's probably not as fast as it could be. I'm not sure you know what element entry to update so let's look at an example:
    -- | Element Entry Id | OVN | Start Date | End Date    | Pay Value |
    -- +------------------+-----+------------+-------------+-----------+
    -- | 123                2    1-Jan-2009   31-Jan-2011   USD 400
    -- | 123                1    1-Feb-2009   18-Jun-2011   USD 500
    -- | 123                1    19-Jun-2011  25-Jun-2011   USD 600
    -- | 123                5    26-Jun-2011  31-Dec-4712   USD 700Here the one element entry (Id 123) has 4 effective rows. The employee gets $400 in Jan 2009, $500 from Feb 2009 to mid-June 2011, $600 for a few days later in June 2011 and then $700 from 26th June 2011 onwards.
    So your question to the forum is which one do I update. Well, that depends which one you want to update. If you want to update the 1st Jan 2009 to 31st Jan 2011 you'd pass element_entry_id => 123, ovn => 2, effective_date => to_date('1-Jan-2009', 'DD-MON-YYYY') and datetrack_mode => 'CORRECTION'.
    If you wanted to update the $700 row you'd pass OVN 5 and an effective date of 26th June 2011. And so-on.
    Now in your SQL you're filtering based on sysdate, which means you'd be updating the $500 row (ovn=1). Is that what you want?
    I have simplified your SQL as follows:
    SELECT pee.element_entry_id
          ,pee.object_version_number
    INTO   x_element_id_mgr
          ,x_ele_object_version_number
    FROM   pay_element_entries_f pee
          ,pay_element_types_f pet
    WHERE  pee.assignment_id = c_staging.assignment_id
    AND    pee.element_type_id = pet.element_type_id
    AND    pet.element_name = 'Mgr Rec Pct'
    AND    trunc(sysdate) BETWEEN
           pee.effective_start_date AND pee.effective_end_date
    AND    trunc(sysdate) BETWEEN
           pet.effective_start_date AND pet.effective_end_date;This selects both the entry Id and OVN in one go; there's no need to have 2 SQL statements. If multiple entries are allowed, this SQL could return more than one row so just watch out for that. If you don't want the row as of sysdate change the two sysdate joins accordingly.
    I hope that helps.

  • How to find the records using contains with the word like this 'some text-some text'?

    Hi,
    How to find the records using the full text contains keyword and that column contains ‘some text-some text’
    In the above some text can be anything.
    Does anybody know please let me know.
    Thanks,

    Hello,
    You can try to create a Full Text Index on the table and use CONTAINS() to get the record which contains the specify words.
    For example:
    SELECT * FROM TABLE WHERE CONTAINS(column_name, 'some text')
    Reference:
    Full-Text Search (SQL Server)
    Creating Full Text Catalog and Full Text Search
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • TS3771 Why can't I select "get info" from the file area so I can change the setting to "open in 32-bit mode" ?

    Why can't I select "get info" from the file area so I can change the setting to "open in 32-bit mode" ?

    It may be because of your settings. You can modify that setting in System Preferences > Trackpad. Another way of making right-click is to click the app icon while holding the Control key

  • The error message "No more virtual tiles can be allocated" appears when I try to use the effects in the quick editing mode in my Elements 13. The baton OK has to be pressed several times for loading all effect patterns. The error returns when selecting th

    The error message "No more virtual tiles can be allocated" appears when I try to use the effects in the quick editing mode in my Elements 13. The baton OK has to be pressed several times for loading all effect patterns. The error returns when selecting the particular pattern.
    The problem does not appear, if PH Elements 13 is executed in the administrator mode.
    The available computer resources are rather  large enough: CPU INTEL i7 4 cores,  16GB RAM, 1TB HDD + 32GB SSD, Windows 8.1.
    Please, advice how to solve this problem? Maybe, there is patch or updating available?

    Dear n_pane,
    Thank you for the quick answer. In the meantime I found other way to pass by the problem. I increased the cache level up to the maximum value 8.
    The errors reported as "No more virtual tiles can be allocated" vanish, but I still do not understand, why PSE 13 cannot work properly by the lower cache levels, having available maximum resources it needed (10443 MB RAM and 26.53GB SSD space for scratches), or cannot collaborate with the fast SSDs properly.
    I wish you all the best in the New Year 2015!

  • Why can I NOT select March 2013 Month Display in iPad's calendar ?

    Why can I NOT select March 2013 Month display in iPad's calendar ?

    Just found out that I had subcribed for a calendar which shows the numbers of the calendar weeks. Turned this off and no crash anymore.
    How can I get the number of calendar weeks in a different way. So that no crashes occur?

  • I am unable to apply my downloaded update. When I try to apply it and restart firefox, it still says 'apply downloaded update now...'. Why can't I apply this update and what do I do about it?

    I am unable to apply my downloaded update. When I try to apply it and restart firefox, it still says 'apply downloaded update now...'. Why can't I apply this update and what do I do about it?

    Checked out that link and everything seems to be in order on this machine at this time.
    I only have CC installed on this one machine, not even my secondary machine like is permitted. it seems odd that I'm asked to re-accept the Licence Agreement as often as I am. If I had to guess, it's almost every week, if not multiple times some weeks, that all the software will decide I should have to view the licence agreement.
    Edit: I've never had any noticeable "errors" activating or anything like that. I just get asked to do it quite frequently.
    This activation screen isn't too annoying (it involves clicking one single button), but like I stated earlier, if I'm trying to launch the software by double-clicking on a PSD, AI, PPROJ, AEP, etc... that file will fail to open.
    I feel like that's probably not really a bug, but it is frustrating, since I did launch the application with the intent to edit that specific file I tried to open.
    Again, something that you guys may consider working on.
    Another annoyance is that: agreeing to the licence agreement is a per-application task, so if I see that Licence Agreement dialogue window by opening Photoshop (for example), I know that every other piece of software I have in the suite (Illustrator, Premiere, After Effects, Audition) will be showing me that screen on it's next launch. Probably deliberate for legal purposes that I can't just agree once for the whole suite, but heck, it would save me a lot of minor headaches if it was a unified agreement.

  • Why can't I download my updates...it doesn't accept my password...changed it several times no luck

    Why can't I download my updates....it says my password is wrong...changed it several times with still no luck. What's wrong? When I login to my apple ID it works..whist am I doing wrong?

    Have you tried logging out of your account by tapping on it in Settings > Store and then logging back in ?
    If that doesn't work then you could try closing the App Store app completely and seeing if you can download updates when you re-open it : from the home screen (i.e. not with the App Store 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of the App Store app to close it, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.
    Another option is a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

  • Why can't I select STUDEN adobe CC plan?

    I tried to buy adobe CC student and I could not even select. Why can I not select student / teacher plan
    Best regards
    Urh

    Athellionn then please contact our support team at http://adobe.ly/1d3k3a5 if a new web browser has not given you the correct option.

Maybe you are looking for

  • Oracle HTTP Server (OHS)  Installation Problem on Win 2003 Server SP2

    Hi, I tried to install Oracle HTTP Server (OHS) on my Windows 2003 server SP2, however I couldn't manage to succeed this. I tried on 3 different win2003 server SP2 machines and couldn't able to install properly. I easily installed and run this HTTP s

  • Unable to type in boby of email.

    Help! I'm able to type in To:, Cc: and Subject:. When I enter text into the body of the email I'm able to type a maybe 8 lettersor numbers and it starts the 'thumping'. Can't Send, Attach. I'm able to QUit but nothing happens. Very strange. Tried rei

  • Purchased Ringtones not showing in Sounds folder

    I have purchased a couple of ringtones from itunes but they are not showing up in my Settings\Sounds\Ringtone folder. How does a person get them into that folder or have the iphone 4s recognize where they are so access can be gained. Currently they c

  • Which is better PI 7.0 r 7.1

    hi all, iam going to install PI in my laptop...??? in market now PI 7.1 is also available...but i dnt knw how successfull it is plzz give me u r valuable suggestions....shld i go for 7.0 r 7.1 thnx in adv kiran

  • Intercompany billing involving three countries

    Hi, I have an intercompany scenario involving three countried. A customer from Romania placed an order on Hungary but the goods are delivered from Poland. We have complaint with tax codes and after investigation we cam eto the conculsion that it coul