How to deal with single quote (') in a field value?

I can successfully insert value with single quoet using
Prepared statement with placeholder(?) construct .
I can also successfuly use value with single quote(') in
WHERE clause.
My question is, is there a way to use string with single
quote if a Statement like:
String slqString ="INSERT INTO customers (name, address) VALUES ( 'O'Reilly Bob', 'St Mary's Street') ";
Statement sqlStmt = con.createStatement();
sqlStmt.executeUpdate(sqlString);
The last statement will thow an SQLException because due to single quotes
Any ideas?

I think the question was regarding the ' in O'Reily. Use ' twice when using the Statement interface, i.e.
("O''Reilly Bob", "St Mary''s Street")
So that's two single quotes, not a double quote, to successfully insert a single quote, if you know what I mean....
But like you said PreparedStatement does things like this for you.

Similar Messages

  • How can i concatenate single quote to a field symbol

    hi
    i have a senario where i have to concatenate a single quote (') to the field symbol. it is simple but i' m not able to do that.
    concatenate ''' <f> ''' into lv_f.
    CONCATENATE lv_condition_temp lv_f INTO
                                   lv_condition_temp
                                           SEPARATED BY space.
    this is the code which i used. could someone help me in solving this...
    thanks & regards,
    subha....

    hi
    i tried using the following code
    data : lv_text(10) type c.
    concatenate ''' <f> ''' into lv_text.
    it is giving me a spelling or incorrect comma error.
    thanks & regards,
    subhashini.

  • IN operator with single quotes

    Hi All,
    I am having problem dealing with Single Quotes with IN operator. Below procedure will explain my problem:
    create or replace procedure sp_countemp
    p_empnames       in   varchar2
    is
    v_cnt            integer:=0;
    BEGIN
    select count(*) into v_cnt from emp where ename in (p_empnames);
    DBMS_OUTPUT.PUT_LINE(v_cnt);
    END;I will be getting p_empnames as 'ALLEN','SMITH'
    But I am not getting any records here.
    Thanks,
    Danish

    Hope this helps..
    DECLARE
      TYPE strarray IS TABLE OF VARCHAR2(100);
      p_empnames STRARRAY;
      v_tot INTEGER :=0;
      v_cnt INTEGER := 0;
    BEGIN
      p_empnames := strarray('Allen','Smith');
      FOR i IN p_empnames.FIRST .. p_empnames.LAST LOOP
          SELECT COUNT(*) INTO v_tot FROM emp WHERE ename = p_empnames(i);
          v_cnt := v_cnt + v_tot;
      END LOOP; 
      DBMS_OUTPUT.PUT_LINE('Count '||v_cnt);
    END;
    Count 2

  • How to concatenate a string with single quotes

    Hi all,
        how to concatenate a string with single quotes to a variable.
    Sathya

    Hi sathyabama,
    1. simple
    2. use TILDE character <b>(`)</b>
       (just left to the '1' key)
    <b> `'mystring'`</b>
    3. just copy paste
    report abc.
    data : m(100) type c.
    concatenate `'amit mittal'` 'hello' into m separated  by space.
    write m.
    regards,
    amit m.

  • How to deal with " and '

    hi evry one, i have query that insert a text in a table. The problem is that the text contain these caracters : ' and ", so how to deal with them.

    Use PreparedStatement and setString. That should escape the single and double quotes properly for you.
    If you've got a String with double quotes in it you'll just have to escape it properly:
    public class DoubleQuoteTester
        public static void main(String [] args)
            for (int j = 0; j < args.length; ++j)
                System.out.println(args[j]);
    }Here's a typical run:
    java DoubleQuoteTester "I quoted the president as saying, \"I forgot!\"" "Quoth the raven 'Nevermore'"
    I quoted the president as saying, "I forgot!"
    Quoth the raven 'Nevermore'

  • Dynamic SQL and Data with Single Quotes in it.

    Hi There,
    I have a problem in that I am using dynamic SQL and it happens that one of the columns does contain single quotes (') in it as part of the data. This causes the resultant dynamic SQL to get confused as the single quote that is part of the data is taken to mean end of sting, when in fact its part of the data. This leaves out a dangling single quote that was meant to enclose the string. Here is my dynamic SQL and the result of the parsed SQL that I have captured:
    ****Dynamic SQL*****
    l_sql:='select NOTE_TEMPLATE_ID '||
    'FROM TMP_NOTE_TEMPLATE_VALUES '||
    'where TRIM(LEGACY_NOTE_CODE)='''||trim(fp_note_code)||''' '||
    'and TRIM(DISPLAY_VALUE)='''||trim(fp_note_text)||''' ';
    execute immediate l_sql INTO l_note_template_id;
    Because the column DISPLAY_VALUE contains data with single quotes, the resultant SQL is:
    ******PARSED SQL************
    select NOTE_TEMPLATE_ID
    FROM TMP_NOTE_TEMPLATE_VALUES
    where TRIM(LEGACY_NOTE_CODE)='INQ' and TRIM(DISPLAY_VALUE)='Cont'd'
    And the problem lies with the single quote between teh characters t and d in the data field for DISPLAY_ITEM. How can I handle this?
    Many thanks,

    I have been reliably informed that if one doesn't enclose char/varchar2 data items in quotes, the right indices may not be usedI am into oracle for past 4 years and for the first time i am hearing this.
    Your reliable source is just wrong. Bind variables are variables that store your value and which are used in SQL. They are the proper way to use values in your SQL. By default all variables in PL/SQL is bind variable.
    When you can do some thing in just straight SQL just do it. Dynamic SQL does not make any sense to me here.
    Thanks,
    Karthick.

  • How to pass a single quote in a URL using Javascript

    Can someone tell me how to pass a single quote in a URL using Javascript. I have created a Javascript funciton in which I pass several column values from an APEX report.
    The URL for the report link I am using is "JAVASCRIPT:passBack('#EMP_ID#','#Name#','#e-mail#')"
    The problem occurs with the Name and e-mail columns contain a single quote (i.e. James O'Brien)

    Thank you Saad, that worked.
    Since I built the report using type 'SQL Query (PL/SQL function fody returning SQL query)' I had to add some additional quotes to get it to work.
    i.e.
    replace(EMP_EMAIL_NAME,'''''''',''\'''''')
    or
    replace(EMP_EMAIL_NAME,chr(39),''\'''''')
    Thanks for the help,
    Jason

  • How to escape a single quotes from a string of dynamic sql clause?

    if a single quotes exist in a dynamic sql clause for a string,
    like
    v_string :='select tname from tab where tabtype='table'',
    there tabtype='table' will conflict with the single quote ahead.
    could somebody tell me how to escape this single quotes?
    thanks for your tips,
    frederick

    fredrick,
    To represent one single quotation mark within a literal, enter two single quotation marks. For example :
    v_string :='select tname from tab where tabtype=''table'''
    Regards,
    Srinivas

  • How to deal with the situation when the database change into ms-sqlserver ?

    Hi,dear all,
    How to deal with the situation when the database change into ms-sqlserver or other database?
    Now, i want to build a j2ee project with ORACLE ADF bc,but this project may be used in several diffrent databases for example oracle db,ms db,mysql and so on.however,if i have developer this project in jdeveloper and this project connection was config as a oracle database,and then,can this project be reused for other databases espasially including the model codes? if yes,how should i do?
    all who know how to resolve this,tell me pls,thanks.
    bruce Li,
    China
    Message was edited by:
    user526724

    Hi Paulbin,
    Do you want to supply a function-pointer to a DLL so it can call[back] your VI?  Here's how it can be done with .NET, though, that solution requires a C compiler.   A single "VI_to_function-reference" utility could handle all cases where the callback passes no parameters.  Maybe someday somebody will share that dll.
    Did you know that LabVIEW can use Events for some COM-signals change?  See pic.  (Note: DTR is not listed - - )
    Another question is another function's prototype is WORD SetTestType(WORD comHandle, bool type1, bool type2, bool type3),   I tried to use a boolean control and a Boolean to (0,1) node in labVIEW to pass parameters to CLF, I config the bool input value as U8(according to C++ bool type) and U32(according to WIN32 BOOL type), it dose not help, when I execute the VI, LabVIEW will be disappeare, it seems to be closed, I must start it again.
    Could someone has similar experience on this points?
    It's easy to crash LabVIEW misusing CLF - maybe there's another reason for the crash besides bool mis-match(?)  Do you know which "Calling convention" is required?  What type is comHandle? (where does comHandle come from?) 
    Cheers!
    Message Edited by tbd on 03-23-2007 09:34 PM
    Message Edited by tbd on 03-23-2007 09:35 PM
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
    Attachments:
    evt.jpg ‏7 KB

  • How to deal with session timeouts?

    How to deal with session timeouts?
    With our current configuration of using single signon, when the web session times out (currently 20 minutes of inactivity), the user loses anything they have entered on a service form.  The use case is that a user starts filling out a form and gets interrupted, goes to lunch, etc, returns and spends time filling out the form (in the mean time the web session has timed out).  When they try to submit the service they get re-logged in through SSO and they have lost all of their entries in the service.   This creates some very unhappy users.
    I'd like to know how long other customers set their web session timeouts to and if anyone has come up with ways of handling this situation - either through somehow re-establishing the session or through warnings to the user about how long they have to complete a form.

    Hi,
    The timeout period for HTTP sessions that are created in the corresponding Web application. After being inactive for the specified timeout, the HTTP sessions expire. The period is specified in minutes:
    <!ELEMENT session-timeout (#PCDATA)>
    You can only change the session timeout property in the applicationu2019s own deployment descriptors. This is not possible for the Global Web Descriptor.
    following may help you:
    [Additional Configuration Settings |http://help.sap.com/saphelp_erp2005vp/helpdata/en/a9/7a9602ad094b82a293f06d1cbe2c14/frameset.htm]
    Regards,
    Sahidur

  • How to deal with deadlock on wwv_flow_data table when http server times out

    There are some threads about a deadlock on the wwv_flow_data table. None of them contain a real explanation for this behaviour. In my case I will try to explain what I think is happening. Maybe it helps somebody who is hitting the same matter.
    In my case with APEX 3.2.1 I am navigating from one page to another. Doing this APEX will lock the table wwv_flow_data. As soon as the other page is shown the lock will be released. But now this other page contains a bad performing query (standaard report region). After 5 minutes the http server (modplsql) will time out and present the message "No response from the application server" on the screen. In the meanwhile the query is still running on the database server and the lock stays on the wwv_flow_data table.
    Normal user behaviour will be that the user will use the back button to return to the previous page and tries it again to navigate to the other page or
    the user will try to refresh the page with the bad performing query.
    And voila now you will have a deadlock on the wwv_flow_data table since a second session is trying to do the same thing while the first hasn't finished yet.
    How to deal with it?
    First of all. Have a good look at the bad performing query. Maybe you can improve it that it will succeed before the http server will timeout.
    In my case the 11gr1 optimizer couldn't handle a subquery factoring clause in the best way. After changing it back to a classical inline query the problem was solved.
    Secondly you could increase the timeout parameter of the http server. Although this not the best way.
    Maybe it would better if APEX in a next version would release the lock on the table wwv_flow_date earlier or do a rollback just before the moment that the http server is timing out.
    regards,
    Mathieu Meeuwissen

    Hello Shmoove,
    I saw your reply here and you probably understand the problems the HTTP 100 response may cause.
    I am trying to send image that was taken by getSnapshot. The problem is that the server respond with this HTTP 100 message.
    I suspect that the reason that my server doesn't recognize the file that I'm sending from J2me is that the "server to client" response to the 100 message comes after the second message of (see what the TCPIP viewer shows down here):
    POST /up01/up02.aspx HTTP/1.1
    Content-Type: multipart/form-data; boundary=xxxxyyyyzzz
    Connection: Keep-Alive
    Content-length: 6294
    User-Agent: UNTRUSTED/1.0
    Host: szekely.dnsalias.com:80
    Transfer-Encoding: chunked
    400: Client to Server (126 bytes)
    78
    --xxxxyyyyzzz
    Content-Disposition: form-data; name="pic"; filename="david.jpg"
    Content-Type: application/octet-stream
    400: Connected to Server
    400: Server to Client (112 bytes)
    HTTP/1.1 100 Continue
    Server: Microsoft-IIS/5.1
    Date: Wed, 23 Mar 2005 00:47:02 GMT
    X-Powered-By: ASP.NET
    Any help will be appreciated,
    David

  • How to escape the single quote from email value?

    Hi,
    Is there any way to escape the special character single quote from the email value.
           String ownerQry = "Select Id, email from User where email in('0000'";
            for(int i=0; i<accountData.length; i++)
                ownerQry += ",'" + accountData.TEAM_EMAIL+"'";
    ownerQry += ")";
    QueryResult qrTeam = sfdcCtrl.query(ownerQry);
    When i tried to set the email value on a custom object, its throwing the error as below  and failed to update. <xml-fragment xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><faultcode>sf:MALFORMED_QUERY</faultcode><faultstring>MALFORMED_QUERY:
    '[email protected]','brenden.o'[email protected]','[email protected]'
    ^ ERROR at Row:1:Column:963 expecting a right parentheses, found 'connor'</faultstring><detail><sf:fault xsi:type="sf:MalformedQueryFault" xmlns:sf="urn:fault.enterprise.soap.sforce.com"><sf:exceptionCode xmlns:sf="urn:fault.enterprise.soap.sforce.com">MALFORMED_QUERY</sf:exceptionCode><sf:exceptionMessage xmlns:sf="urn:fault.enterprise.soap.sforce.com">
    '[email protected]','brenden.o'[email protected]','[email protected]'
    ^ ERROR at Row:1:Column:963 expecting a right parentheses, found 'connor'</sf:exceptionMessage><sf:row xmlns:sf="urn:fault.enterprise.soap.sforce.com">1</sf:row><sf:column xmlns:sf="urn:fault.enterprise.soap.sforce.com">963</sf:column></sf:fault></detail></xml-fragment>

    Thanks Dr.Clap.
    I think its very tricky to implement this.
    Here is the SOQL query. i am passing all the email values.
    Select Id, email from User where email in('0000','o\'[email protected]','[email protected]')
    These values are coming from oracle DB table in the form of array accountData[].TEAM_EMAIL
            String ownerQry = "Select Id, email from User where email in('0000'";
            for(int i=0; i<accountData.length; i++)
               ownerQry += ",'" + accountData.TEAM_EMAIL+"'";
    ownerQry += ")";the array value may contain the email with single quote before @gmail.com which i need to ignore. :-( i think this is very tricky. who knows the solution for this?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to deal with OpenCL grey out issue.

    First off, I'm not native english speaker.
    I have Nvidia GeForce 550 Ti video card, and its support OpenCL v1.1.
    I'm also face a "random" OpenCL grey out issue like other people here, but I found the "issue" and how to deal with.
    open a command windows (using WinKey + R, and type cmd <enter>)
    type "cd C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)" <enter>
    type "sniffer_gpu" <enter>  -->> to check your GPU has OpenCL in Photoshop?
    When GPU is in power-saving mode (core running in 51Mhz, using MSI Afterburner monitor), I running sniffer_gpu, got this report
    C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)>sniffer_gpu
    Device: 0000000000328D68 has video RAM(MB): 1023
    Vendor string:    NVIDIA Corporation
    Renderer string:  GeForce GTX 550 Ti/PCIe/SSE2
    Version string:   3.0.0
    OpenGL version as determined by Extensionator...
    OpenGL Version 3.0
    Has NPOT support: TRUE
    Has Framebuffer Object Extension support: TRUE
    OpenGL ok
    Return code: 1
    C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)>
    No OpenCL support
    Then, I switch GPU back to normal status (core running at 900Mhz)
    C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)>sniffer_gpu
    Device: 00000000001F8D68 has video RAM(MB): 1023
    Vendor string:    NVIDIA Corporation
    Renderer string:  GeForce GTX 550 Ti/PCIe/SSE2
    Version string:   3.0.0
    OpenGL version as determined by Extensionator...
    OpenGL Version 3.0
    Has NPOT support: TRUE
    Has Framebuffer Object Extension support: TRUE
    OpenGL ok
    OpenCL ok, version=1.1 CUDA 4.2.1
    Return code: 3
    C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)>
    OpenCL support !!
    Nowadays, most of new GPUs were support power-saving, but when sniffer_gpu running at GPU power-saving state, the OpenCL computing report maybe "time-out", cause the detector "guess" the GPU does not support OpenCL. This is why many people says "OpenCL" sometimes work, sometimes grey-out.
    I hope this bug can be fixed, or at least people can understand how to "enable OpenCL everytime when you launch photoshop".
    Bye.

    Do check the following link
    http://blogs.oracle.com/soabpm/2010/01/soa_suite_11g_weblogictransact.html

  • How to deal with "Error 1001. The specified service already exists" when install a service using installer package?

    Hi everybody,
    I wrote a "Class Library" project which is a service using Visual Stodio 2008 recently, then tried to use a Visual Studio 2008
    Setup Project to install it.
    Here is what I did for the "Class Library":
    1. Finish the program.cs, Service.cs
    2. Add Installer
    3. Change the serviceInstaller so that "StartType" to be Aotumatic
    4. Change the ServiceProcessInstaller2 so that "Account" to be LocalSystem
    5.
    6. Click in F5 (Start Debugging)
    Here is what I did for the Setup Project:
    1. Add the exe file built from the "Class Library" project to the Application Folder
    2. On the Custom Action Editor, add the exe file from 1 to Install and Commit
    3. Change the property of the project so that "RemovePreviousVersion" to be true
    4. Click on F6(Build Solution)
    Then I tried to run the msi file from the built of the Setup Project. Because I modified the two projects serveral times, I uninstalled the Class Library using "Control Panel->Add or Remove Programs" before I reinstall. Two things I notived:
    1. After unstall, the registry was not cleaned up about the installed program
    2. After several rounds install/uninstall, I got "Error 1001. The specified service already exists"
    My questions are:
    1. How to cleanup the registry when uninstall a program?
    2. How to deal with the "Error 1001. The specified service already exists"?
    3. Did I do anytbing wrong with the "Class Library" or the "Setup Project"?
    Thanks a lot!
    Helen

    Hi Simon, not a problem!
    I spent some more time on this and here are few more notes:
    it is called Major Upgrade, when you are installing new version of the product upon a previous one and
    MSI supports 2 strategies:
    Strategy 1. Install a new version and uninstall previous one. (Install a new version right upon previously installed version (file merging is performed based on dll version number) and the delete previously
    installed files)
    Strategy 2. Uninstall previous version and install a new one (Delete all previous files and install from scratch new files.)
    From the first look it seems that 1st strategy is weird and buggy. But, remember, MSI is great because it's transactional!!! That means that if once some of the phases (Installation, Uninstallation, Rollback, Comit) fails, your machine
    will be reverted to the previous state and it'll be still functional. 
    Let's consider both strategies:
    Consider you have installed product_v1.msi and you want to install product_v2.msi.
    Strategy 1
    1. MSI engine copies files from Product_v1 directory to TEMP directory
    2. MSI engine merges files based on the assembly version (between v1 and v2)
    3. Once merging is completed successfully it removes files in TEMP (RemoveExistingProducts  action triggers it) and you got product_v2 installed, otherwise if it fails MSI engine revert machine to V1 and copies previous files from TEMP.
    Strategy 2
    1. MSI engine tottaly removes all files from v1.
    2. MSI engine installs v2 files and if something goes wrong you cannot revert back, because RemoveExistingProducts  allready worked out and MSI doesn't have files to revert machine back
    I recommend to everybody to use Strategy 1 and leverage MSI transaction functionality. And you can set this strategies by defining sequence of RemoveExistingProducts action. See more info
    here.  So, I think it's not even a bug in VS as I said in the upper post it is default recommened behaviour.
    AND, you got "Error 1001. The specified service already exists"
    because if we follow Strategy 1 MSI engine tries to install Windows Service on top of the existing service and OF COURSE it fails MSI engine (StopServices, DeleteServices actions are executed before actual
    installation and  they look at ServiceControl table). In order to stop service first and delete them you have to fill ServiceContol table of the MSI (and then StopServices, DeleteServices actions will recognize what to they have to stop
    and delete), like this:
    *clip*clip*clip*
    ' see http://msdn.microsoft.com/en-us/library/windows/desktop/aa371634(v=vs.85).aspx for more info
    ' Update the Service Entry to stop and delete service while uninstalling
    query = "INSERT INTO ServiceControl (ServiceControl, Name, Event, Arguments, Wait, Component_) VALUES ('MAD_Service', 'Service name', '160', '', '1', '"
    + componentName + "')"
    Set view = database.OpenView(query)
    : CheckError
    view.Execute : CheckError
    ' Update the Service Entry to stop and delete service while installing
    query = "INSERT INTO ServiceControl (ServiceControl, Name, Event, Arguments, Wait, Component_) VALUES ('MAD2_Service', 'Service name', '10', '', '1', '"
    + componentName + "')"
    Set view = database.OpenView(query)
    : CheckError
    view.Execute : CheckError
    *clip*clip*clip*
    We can uninstall service first by following Strategy 2, but then we lose transactional support.
    So, Simon did I encourage you to change your code a bit?:)
    And, btw, if you don't want to change the strategy, please don't rely on SequenceID in MSI table, it can be change, you have to get the at the runtime.
    Hope it will help to everybody!
    See also more advanced explanation of how MSI works
    here.
    Truly yours, Marat

  • How to deal with credentials for external applications using a Java Client/

    Hi Guys,
    This is the case. I am integrating an external application with an ADF Application. I have implemented some programmatic ViewObjects that are being filled up by a REST Java Client Wrapper. Everything is working fine but the issue is that the credentials the wrapper is using are hard coded inside the java class. I am thinking to ask for the credentials at the beginning of my taskflow and then store them somewhere and use them then to create my client wrapper (passing them in the constructor).
    However, I don't know if my approach is good and I would like you to share your experiences or how to deal with this.
    Regards

    You can use Credential Store Framework to store the credentials securely in the weblogic server instead of hardcoding in the java class.
    The Credential Store Framework:
    - enables you to manage credentials securely
    - provides an API for storage, retrieval, and maintenance of credentials in different back-end repositories
    Check the documentation on CSF API -
    http://docs.oracle.com/cd/E29505_01/core.1111/e10043/devcsf.htm
    Major Steps -
    1. Create a credential map and key in em console to store the password (http://docs.oracle.com/cd/E25054_01/core.1111/e10043/csfadmin.htm)
    2. Use CSF API to retrieve the stored password
    3. In jazn-data.xml give permissions to access CSF key and map

Maybe you are looking for

  • Safari on ipod touch

    Hi I have had the touch since xmas, no problem so far ( my first Ipod!) with itunes etc and synching. But trying to surf safari is saying "cant find server" The radar is showing its located the wi fi but the browser doesnt load up any pages from any

  • Videos NOR Music will load after SYNC, Please HELP

    Hello everyone, I have an iPad and Recently bought RIO to watch on the iPad. After it downloaded I could not find it anywhere! So I synced to my iTunes and there it was....after the iPad was done syncing I ejected it.... And NOW the Music folder NOR

  • Set context privilages issue

    Hi I create a procedure but get this error. CREATE OR REPLACE package body SearcProduct_Pkg  is procedure SearchProVar(PCode in varchar2, Storeid in number,Usertype in varchar2) is begin dbms_session.set_context( namespace => 'paramsNew1', attribute

  • Acrobat DC Pro Compare 2 Versions Gives Distorted Results

    When attempting to compare 2 pdf versions in Acrobat DC Pro, the highlighted results become distorted.  Can only view the compare results by hovering over each word or zooming in enough to see the highlighted word.  Is this a known issue in DC? We di

  • Moving through a hyperlink

    I created a hyperlink on a slide, which took me to my website. Is it possible to go from the website to the next slide in the presentation, or do I need to return via the previous (hyperlinked) slide? PowermacG5   Mac OS X (10.4.2)