Escaping Apostrophes

I need to be able to insert text values, which I retrieve from text fields in one of my JSP pages, that have an apostrophe within them into one of my Oracle tables.
I've figured out how to do this by using PreparedStatements, however, the only way it'll work is if I hard-code the strings that have apostrophes. But this can't work since I retrieve values from users of my system. I retrieve these values using a String variable. How can I escape apostrophes or quotes through Java code before I use PreparedStatements to insert them into my table. If I don't escape the apostrophe through code first, the PreparedStatement doesn't work properly and won't insert my text into my table.
Thanks

You retrieve the string from the user via whatever means you want. It has some apostrophes in it (single quotes). Before you pass that string to a prepare function, double-up each of the single quotes. Where there is one, put another right beside it. Then, submit THAT string to the prepare function.
Tom Best

Similar Messages

  • How to escape apostrophe in Oracle PL/SQL  dynamic queries

    I have an script that receives an string as a parameter, for example:
    @C:/myScript.sql "AXEL";
    @C:/myScript.sql "AXEL DAVID";
    @C:/myScript.sql "o'neal";
    my scripts basically constructs a Parameterized query an execute it. That's all. It works most of the time, except when the parameter contains apostrophes
    DEFINE myparameter = &&1
    myquery := "Select * from myTable where x = :p1";
    EXECUTE IMMEDIATE myquery into results USING myparameter;
    ...When trying the following;
    @C:/myScript.sql "o'neal";
    I get the following error:
    Bind Variable "p1" is NOT DECLARED
    Of course if I change the parameter as "o''neal" It will work, but I will end up with other issues later on, so I would like to know how can I deal with apostrophe on dynamic queries.
    I also tried to use the following:
       myquery := "Select ....  where x = " || Q'#:p1#';
    ...but not working.
    any hint will be appreciated =)
    Edited by: user13679988 on Nov 22, 2012 3:12 PM
    Edited by: user13679988 on Nov 22, 2012 3:38 PM
    Edited by: user13679988 on Nov 22, 2012 3:45 PM

    DUPLICATE THREAD! and WRONG FORUM!
    This forum is for SQL Developer questions only and your question has nothing to do with sql developer. Please mark this question ANSWERED.
    You have already posted this question in the SQL and PL/SQL forum and should continue to use that thread.
    How to replace 2 single quotes to single quote

  • Import from Excel not escaping quote (')

    Hi,
    I'm having problems with text fields in an Excel spreadsheet that contain single quotes (') not being escaped when the insert commands are built using the Import from Excel wizard.
    It's pretty much the same problem as that described in the post below (but for importing Excel spreadsheets):
    <Re: DDL in the SQL tab does not escape apostrophes
    SQLDev 1.2.1.32.00
    WinXP SP2
    Excel 2003
    Any chance of getting this fixed?
    Thanks,
    Simon

    OK, so have updated to
    SQLDev 1.2.1.32.13
    and still see problem when importing from Excel.
    The generated SQL looks like this:
    insert into INV_CONTAINERS (CONTAINER_NAME) VALUES('Tetramethylethylenediamine, N,N,N',N'-');
    That's supposed to be just one item in the VALUES term.
    Is there another way to do this? If not, how do I lodge this as a bug?
    Simon

  • Escaping Apostophes

    I need to be able to insert text values, which I retrieve from text fields in one of my JSP pages, that have an apostrophe within them into one of my Oracle tables.
    I've figured out how to do this by using PreparedStatements, however, the only way it'll work is if I hard-code the strings that have apostrophes. But this can't work since I retrieve values from users of my system. I retrieve these values using a String variable. How can I escape apostrophes or quotes through Java code before I use PreparedStatements to insert them into my table. If I don't escape the apostrophe through code first, the PreparedStatement doesn't work properly and won't insert my text into my table.
    Thanks

    If you have to fiddle with the apostrophe or the PreparedStatement won't work, then you are using the PreparedStatement wrong. Here's what your code should look like, roughly:PreparedStatement inserter = conn.prepareStatement("Insert into Flamingo values(?)");
    inserter.setString(1, theStringYouGotFromTheUser);
    inserter.executeUpdate();Note: not compiled or checked for accuracy.

  • Physical SQL contains apostrophe

    In OBIEE-11g, how can we escape apostrophe in physical SQL. For example a filter that contains member name(Amy O'Brien) is being sent as 'where member_name ='Amy O''''Brien'. The four quotes are leading to mismatch of the conditiona and hence not returning any results.
    Thanks

    I don't see it in NQQuery log:(
    Ideally, it should be because it will hit BI Server. Moreover, I can see it (report's logical SQL) in BI Server Cache.
    Any other thoughts?

  • How to Disable the Add & Review Button

    How to Disable the Add & Review Button
     *Updated with the correct ISF  code (the previous code, in case you saved it, was to actually  escape apostrophes.  That will be posted  seperately. 
    Note that this solution might not work in your environment - you might have to modify it based on your installation.
    Enjoy! 
    Common_disableAddAndReviewButton()
       if ( Moment == 'ordering' )
            var theForm = document.forms[0];
            var buttonCt = 0;
            for( i = 0; i &lt; theForm.elements.length; i++ )
                 if( theForm.elements[i].type == &quot;submit&quot; )
                    if ( buttonCt == 0 || buttonCt == 2 )
                        theForm.elements[i].disabled = true;
                         theForm.elements[i].style.visibility=&quot;hidden&quot;;                  
                     buttonCt++;              

    This is GREAT - I added a new Java Script and set it to "when form is loaded" and when I did some test reqs - no Add & Review button !!!!

  • JAVA regular Expression problem

    i have a string AS FOLLOWS-
    "N\E'\ERAJ";
    u can create this string as --- > String str="N\\E'\\ERAJ "
    i want output as below--
    N\\E\'\\ERAJ
    don't us the looping.
    Thanks in advance.
    nJoy the Regular Expression.

    String myString = myString.replaceAll("\","\\");No. To merely double all backslashes, you would use  myString = myString.replaceAll("\\\\", "\\\\\\\\");But it looks like the OP wants to escape apostrophes as well:  myString = myString.replaceAll("(['\\\\])", "\\\\$1");...or possibly all punctuation characters:  myString = myString.replaceAll("(\\p{Punct})", "\\\\$1");

  • Escape character for apostrophe ' in JDBC receiver channel

    Hi all,
    We have Proxy to JDBC scenario in our project. This interface is working fine with unicode data but when there is an apostrophe( ' ) coming in any of the field values ( ex: DOWTHERM 'J' MODEL19QAGB1G ) , the message is failing in receiver JDBC channel.
    can anyone please tell us how to handle single quote in JDBC receiver channel.
    I have read in SAP help documentation that apostrophe is a reserved character in SQL syntax and is therefore replaced by an escape character if it occurs within value strings. There is a option to JDBC receiver communication channel under "SQL SYNTAX PARAMETER"  to specify the escape character for apostrophe.
    Can any please tell us which value needs to be maintained in the channel to avoid this error.
    Regards
    Jagruthi

    Hi Prateek,
    Thanks a lot for you inputs.
    This issue is solved now. We have replaced single quote with two single quotes and then did the hasQuote mapping as described in the blog.
    /people/prateek.srivastava3/blog/2009/04/02/unicode-handling-for-ms-sql-server
    No value needs to be maintained in channel(SQL SYNTAX PARAMETER ).
    But just want to understand  the difference between replacing the ' with '' in mapping and using SQL SYNTAX PARAMETER option in communication channel.
    Both should ideally result in same  output. But it didnu2019t work when we tried with two single quotes in SQL SYNTAX PARAMETER (Escape Symbol for Apostrophe) in communication channel without doing anything in mapping.
    Regards
    Jagruthi

  • Escaping "curly apostrophe" for a sql statement

    Hi,
        I'm trying to escape the curly apostrophe for a sql statement, i.e.,
    Bob’s . I tried using the following
    string str = inputStr.Replace("'","''");
    Of course, this doesn't work.
    Thanks!

    Replace has 2 overloads.  One uses 2 strings while the other uses 2 char parameters.  Run this code on text pasted from each application.
    static string ReplaceString()
    string input =
    "O'Hara";
    foreach ( Char c
    in input )
    Console.WriteLine(c.ToString() +
    " = " + Convert.ToInt32(c).ToString());
    return input.Replace("'",
    String.Empty);
    Compare the values returned for the character.  Then use the char value from Word and replace it with the char value from Notepad in the other overload that takes 2 char parameters.
    Are you using a TextBox or a RichTextBox?
    Mark the best replies as answers. "Fooling computers since 1971."
    http://rudedog2.spaces.live.com/default.aspx

  • JRC bug: apostrophe in string parameter passed to Crystal Report with Command datasource to SQL Server

    Post Author: nl11087
    CA Forum: JAVA
    A single quote/apostrophe in string parameter passed to a Crystal Report with Command datasource connecting to a SQL Server database, using sqljdbc driver does not escape the special character correctly. When doing a preview in the Crystal Reports IDE it allows you to escape the input parameter as expected and work correctly, but through the JRC component it fails. For string parameters without special sql server characters I experience no problems at all. When replacing the Command with a direct table there is also no problem.
    Reproduction:
    1. create a database db1, create a table table1 with a String type column col1.
    2. Create new report Report1.rpt, create a connection to above, Add Command using 'SELECT col1, col2, col3 FROM table1 WHERE col1 = '{?Par1}' . Add a parameter field Par1 : String
    3. In your java stand alone application using JRC add the parameter Par1 with a value "Jon Doe's Value" containing a single apostrophe. Export to PDF. (I also tried MSWord and this failed too, similar behavior). Additionally, in another test try to replaceAll("'","''") to escape it, preventing the code to break, but now it does not retrieve the expected row anymore and you end up with an empty report.
    Exception StackTrace:
    com.crystaldecisions.reports.exportinterface.exceptions.ExportException: JDBC Error: Incorrect syntax near 's'.
    at com.crystaldecisions.reports.formatter.a.c.if(Unknown Source)
    at com.crystaldecisions.reports.formatter.a.c.a(Unknown Source)
    at com.businessobjects.reports.sdk.b.b.int(Unknown Source)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)
    at com.crystaldecisions.proxy.remoteagent.x.a(Unknown Source)
    at com.crystaldecisions.proxy.remoteagent.q.a(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.dd.a(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
    at com.crystaldecisions.reports.sdk.PrintOutputController.export(Unknown Source)
    Caused by: com.crystaldecisions.reports.formatter.formatter.c: JDBC Error: Incorrect syntax near 's'.
    at com.crystaldecisions.reports.formatter.formatter.objectformatter.bv.<init>(Unknown Source)
    at com.crystaldecisions.reports.formatter.formatter.objectformatter.bv.if(Unknown Source)
    at com.crystaldecisions.reports.formatter.formatter.e.l.<init>(Unknown Source)
    at com.crystaldecisions.reports.formatter.formatter.e.p.<init>(Unknown Source)
    at com.crystaldecisions.reports.formatter.formatter.e.p.a(Unknown Source)
    at com.crystaldecisions.reports.formatter.a.c.a(Unknown Source)
    ... 17 more
    Caused by: com.crystaldecisions.reports.dataengine.be: JDBC Error: Incorrect syntax near 's'.
    at com.crystaldecisions.reports.dataengine.n.else(Unknown Source)
    at com.crystaldecisions.reports.dataengine.n.nr(Unknown Source)
    at com.crystaldecisions.reports.dataengine.n.bn(Unknown Source)
    at com.crystaldecisions.reports.dataengine.n.bp(Unknown Source)
    at com.crystaldecisions.reports.dataengine.n.else(Unknown Source)
    at com.crystaldecisions.reports.dataengine.s.a(Unknown Source)
    at com.crystaldecisions.reports.dataengine.bk.a(Unknown Source)
    at com.crystaldecisions.reports.dataengine.bk.aa(Unknown Source)
    at com.crystaldecisions.reports.dataengine.bk.<init>(Unknown Source)
    at com.crystaldecisions.reports.dataengine.bk.<init>(Unknown Source)
    at com.crystaldecisions.reports.dataengine.bk.<init>(Unknown Source)
    at com.crystaldecisions.reports.dataengine.bk.a(Unknown Source)
    ... 23 more
    Caused by: com.crystaldecisions.reports.reportdefinition.datainterface.n: JDBC Error: Incorrect syntax near 's'.
    at com.crystaldecisions.reports.reportdefinition.datainterface.p.a(Unknown Source)
    ... 35 more
    Caused by: com.crystaldecisions.reports.queryengine.driverImpl.m: JDBC Error: Incorrect syntax near 's'.
    at com.crystaldecisions.reports.queryengine.driverImpl.o.eC(Unknown Source)
    at com.crystaldecisions.reports.queryengine.driverImpl.o.if(Unknown Source)
    at com.crystaldecisions.reports.queryengine.ap.ea(Unknown Source)
    at com.crystaldecisions.reports.queryengine.ap.h(Unknown Source)
    at com.crystaldecisions.reports.queryengine.ap.dV(Unknown Source)
    at com.crystaldecisions.reports.queryengine.ax.if(Unknown Source)
    at com.crystaldecisions.reports.queryengine.bc.if(Unknown Source)
    at com.crystaldecisions.reports.queryengine.bc.do(Unknown Source)
    at com.crystaldecisions.reports.queryengine.bc.do(Unknown Source)
    at com.crystaldecisions.reports.queryengine.ae.cy(Unknown Source)
    at com.crystaldecisions.reports.queryengine.ae.cz(Unknown Source)
    at com.crystaldecisions.reports.queryengine.b1.bc(Unknown Source)
    ... 36 more
    Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 's'.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
    at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement$StatementExecutionRequest.executeStatement(Unknown Source)
    at com.microsoft.sqlserver.jdbc.CancelableRequest.execute(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeRequest(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.execute(Unknown Source)
    ... 48 more
    - JRCAgent3 detected an exception: An error occured while exporting the report
    at com.businessobjects.reports.sdk.b.b.int(Unknown Source)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)
    at com.crystaldecisions.proxy.remoteagent.x.a(Unknown Source)
    at com.crystaldecisions.proxy.remoteagent.q.a(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.dd.a(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
    at com.crystaldecisions.reports.sdk.PrintOutputController.export(Unknown Source)

    Post Author: nl11087
    CA Forum: JAVA
    A single quote/apostrophe in string parameter passed to a Crystal Report with Command datasource connecting to a SQL Server database, using sqljdbc driver does not escape the special character correctly. When doing a preview in the Crystal Reports IDE it allows you to escape the input parameter as expected and work correctly, but through the JRC component it fails. For string parameters without special sql server characters I experience no problems at all. When replacing the Command with a direct table there is also no problem.
    Reproduction:
    1. create a database db1, create a table table1 with a String type column col1.
    2. Create new report Report1.rpt, create a connection to above, Add Command using 'SELECT col1, col2, col3 FROM table1 WHERE col1 = '{?Par1}' . Add a parameter field Par1 : String
    3. In your java stand alone application using JRC add the parameter Par1 with a value "Jon Doe's Value" containing a single apostrophe. Export to PDF. (I also tried MSWord and this failed too, similar behavior). Additionally, in another test try to replaceAll("'","''") to escape it, preventing the code to break, but now it does not retrieve the expected row anymore and you end up with an empty report.
    Exception StackTrace:
    com.crystaldecisions.reports.exportinterface.exceptions.ExportException: JDBC Error: Incorrect syntax near 's'.
    at com.crystaldecisions.reports.formatter.a.c.if(Unknown Source)
    at com.crystaldecisions.reports.formatter.a.c.a(Unknown Source)
    at com.businessobjects.reports.sdk.b.b.int(Unknown Source)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)
    at com.crystaldecisions.proxy.remoteagent.x.a(Unknown Source)
    at com.crystaldecisions.proxy.remoteagent.q.a(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.dd.a(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
    at com.crystaldecisions.reports.sdk.PrintOutputController.export(Unknown Source)
    Caused by: com.crystaldecisions.reports.formatter.formatter.c: JDBC Error: Incorrect syntax near 's'.
    at com.crystaldecisions.reports.formatter.formatter.objectformatter.bv.<init>(Unknown Source)
    at com.crystaldecisions.reports.formatter.formatter.objectformatter.bv.if(Unknown Source)
    at com.crystaldecisions.reports.formatter.formatter.e.l.<init>(Unknown Source)
    at com.crystaldecisions.reports.formatter.formatter.e.p.<init>(Unknown Source)
    at com.crystaldecisions.reports.formatter.formatter.e.p.a(Unknown Source)
    at com.crystaldecisions.reports.formatter.a.c.a(Unknown Source)
    ... 17 more
    Caused by: com.crystaldecisions.reports.dataengine.be: JDBC Error: Incorrect syntax near 's'.
    at com.crystaldecisions.reports.dataengine.n.else(Unknown Source)
    at com.crystaldecisions.reports.dataengine.n.nr(Unknown Source)
    at com.crystaldecisions.reports.dataengine.n.bn(Unknown Source)
    at com.crystaldecisions.reports.dataengine.n.bp(Unknown Source)
    at com.crystaldecisions.reports.dataengine.n.else(Unknown Source)
    at com.crystaldecisions.reports.dataengine.s.a(Unknown Source)
    at com.crystaldecisions.reports.dataengine.bk.a(Unknown Source)
    at com.crystaldecisions.reports.dataengine.bk.aa(Unknown Source)
    at com.crystaldecisions.reports.dataengine.bk.<init>(Unknown Source)
    at com.crystaldecisions.reports.dataengine.bk.<init>(Unknown Source)
    at com.crystaldecisions.reports.dataengine.bk.<init>(Unknown Source)
    at com.crystaldecisions.reports.dataengine.bk.a(Unknown Source)
    ... 23 more
    Caused by: com.crystaldecisions.reports.reportdefinition.datainterface.n: JDBC Error: Incorrect syntax near 's'.
    at com.crystaldecisions.reports.reportdefinition.datainterface.p.a(Unknown Source)
    ... 35 more
    Caused by: com.crystaldecisions.reports.queryengine.driverImpl.m: JDBC Error: Incorrect syntax near 's'.
    at com.crystaldecisions.reports.queryengine.driverImpl.o.eC(Unknown Source)
    at com.crystaldecisions.reports.queryengine.driverImpl.o.if(Unknown Source)
    at com.crystaldecisions.reports.queryengine.ap.ea(Unknown Source)
    at com.crystaldecisions.reports.queryengine.ap.h(Unknown Source)
    at com.crystaldecisions.reports.queryengine.ap.dV(Unknown Source)
    at com.crystaldecisions.reports.queryengine.ax.if(Unknown Source)
    at com.crystaldecisions.reports.queryengine.bc.if(Unknown Source)
    at com.crystaldecisions.reports.queryengine.bc.do(Unknown Source)
    at com.crystaldecisions.reports.queryengine.bc.do(Unknown Source)
    at com.crystaldecisions.reports.queryengine.ae.cy(Unknown Source)
    at com.crystaldecisions.reports.queryengine.ae.cz(Unknown Source)
    at com.crystaldecisions.reports.queryengine.b1.bc(Unknown Source)
    ... 36 more
    Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 's'.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
    at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement$StatementExecutionRequest.executeStatement(Unknown Source)
    at com.microsoft.sqlserver.jdbc.CancelableRequest.execute(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeRequest(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.execute(Unknown Source)
    ... 48 more
    - JRCAgent3 detected an exception: An error occured while exporting the report
    at com.businessobjects.reports.sdk.b.b.int(Unknown Source)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)
    at com.crystaldecisions.proxy.remoteagent.x.a(Unknown Source)
    at com.crystaldecisions.proxy.remoteagent.q.a(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.dd.a(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
    at com.crystaldecisions.reports.sdk.PrintOutputController.export(Unknown Source)

  • Problem with apostrophe  in javascript

    Hi all,
    I have a text retrieved from the database.It has apostrophe in it. Since the value is dynamic,i cannot manually use backslash to escape the apostrophe.my javscript coding isnt working if the text contains apostrophe.Help me out to solve the problem.
    Thanks in Advance

    hi,
    I tried with the replace function
    <%String s="yahoo's mail's";
    String s1=s.replaceAll("'","\'");
    System.out.println("---------------------------------------"+s1);
    %>I am replacing"{color:#ff0000} *'*{color} " with "{color:#ff0000} *\'*{color} "
    The expect the output to be yahoo\'s mail\'s.
    But the output is yahoo's mail's.
    I don't the mistake i am making here.Help me out.
    thanks
    Edited by: beginjava on Nov 10, 2008 5:04 AM

  • Using an apostrophe in a substitution variable

    Hello, I have a simple sql plus script which sets a substitution variable and then uses this in an INSERT statement to insert the value of the variable into a database table.
    For example:
    DEFINE TEXT = 'For full details see PQPs website'
    insert into CONSTS(PARAMETER, VALUE, TYPE) values ('admin.marketing.website', '&TEXT1', 'ADMIN');
    That's all fine and dandy.
    However, I want to put a possessive apostrophe in PQPs, i.e. PQP's but can't find a way that lets me do it and I've tried everything I can think of.
    Using the escape character \ doesn't work
    i.e.
    set escape \
    DEFINE TEXT = 'For full details see PQP\'s website'
    I just get the string 'For full details see PQP\'
    Also using two apostrophes doesn't work either
    i.e.
    DEFINE TEXT = 'For full details see PQP''s website'
    I get the error "ORA-01756: quoted string not properly terminated"
    when I try and insert into the database.
    I've tried surrounding the value in double quotes etc. and everything I can think of but for the life of me I can't get a string containing an apostrophe into the database using a substitution variable. It must be possible though, isn't it?
    Thanks
    Andy Birchall

    Could this be a solution ?
    TEST@db102 > var text varchar2(50);
    TEST@db102 > exec :text := 'For full details see PQP'||chr(39)||'s website';
    PL/SQL procedure successfully completed.
    TEST@db102 > insert into CONSTS(PARAMETER, VALUE, TYPE) values ('admin.marketing.website', :text, 'ADMIN');
    1 row created.
    TEST@db102 > select * from consts;
    PARAMETER                      VALUE                                              TYPE
    admin.marketing.website        For full details see PQP's website                 ADMIN
    TEST@db102 >

  • S3 backup can't upload files with apostrophe​s in the name

    s3 backup doesn't seem to be able to upload any file with an apostrophe in the name.  I see a load of "Unable to upload 'foo bar's.file' to Amazon S3" warnings in the event log.  The log is littered with file names that contain an apostrope.  This seems to be the thing that stands out in common with all of the failed transfers.  Is there some way to workaround the problem besides renaming all files containing apostropes?
    It seems like an easy fix to properly escape single quotes in the name for upload though, but I suppose that I'll need a firmware fix for a change like that.

     Hello spitzcor
    Have you checked your Amazon S3 account to see if the files have actually uploaded to the bucket or if they did indeed fail to upload?
    I also recommend that you contact support to have an incident created.  There is a hotfix for 4.1.108 that updates the Amazon S3 applications API version and might help with what you are experiencing, although it is intended for a seperate Amazon S3 issue.
    LenovoEMC Contact Information is region specific. Please select the correct link then access the Contact Us at the top right:
    US and Canada: https://lenovo-na-en.custhelp.com/
    Latin America and Mexico: https://lenovo-la-es.custhelp.com/
    EU: https://lenovo-eu-en.custhelp.com/
    India/Asia Pacific: https://lenovo-ap-en.custhelp.com/
    http://support.lenovoemc.com/

  • Escape Characters - simulate the setString from Prepared Statements

    I would like to see what the value of setString() is for a given prepared statement call.
    Because of reasons that would take me to long to explain that I cannot use preparedstatements with their parameters - I need a way to execute a query like the following:
    String query = "insert into blahtable (somestring) values (\"asdfds\'\s sdsfdasfd \"\& ...\");
    PreparedStatement stmt = connection.prepareStatement(query);
    I know prepared statements can take care of this, but I want to know and write the query as above without the need of prepared statements help for string.
    Below is an example with prepared statement - but not what I want to do
    For example:
    String oddstringwithunusalcharacters = "...";
    String query = "insert into blahtable (somestring) values (?)";
    PreparedStatement stmt = connection.prepareStatement(query);
    stmt.setString(1, oddstringwithunusalcharacters);
    I would like to see what the actual query looks like and what the actual string was passed:
    --> insert into blahtable (something) values ("asdfds\'\s sdsfdasfd \"\& .... ")
    It is not sufficient enough for me to escape quotes and apostrophes because there maybe other unusual characters that I do not know of since the string is passed by an unknown source.
    Thank you in advance

    PreparedStatements actually doesn't escape quotes. It basically precompiles statements in the DB and only passes the values to the DB.
    But if you're using a plain vanilla SQL statement where you quote the string with a single quote ' then you need to escape all occurrences of exactly the same single quote ' in the actual String value. If you for example quote the string with an apostrophe ` then you just need to escape all occurrences of exactly the same apostrophe ` in the actual String value. And so on. It is nothing more than logical, is it?

  • SQL*Plus: list of characters that need to be escaped

    Hi all,
    We have a requirement where we need to add comments to tables and table columns and this is done using SQL*Plus. I understand that there are some special characters that are interpreted by SQL*Plus such as ampersand (&). I would like to know the list of such characters so that we can escape them before passing it on to CREATE COMMENT ON statement. So far we have identified the following special characters:
    The following characters need to be escaped no matter where they are present in the comment
    single quote "'" (hex 27)
    define "&" (hex 26)
    sqlterminator ";" (hex 3b)
    The following characters need to be escaped when they are the only character on a line
    forward slash "/" (hex 2f)
    blockterminator "." (hex 2e)
    sqlprefix "#" (hex 23)
    The following characters need to escaped if they are followed by a newline
    line continuation "-" (hex 2d)
    We would like to know if there are other special characters and appreciate if someone can provide the list.
    Thanks
    Edited by: user779842 on Aug 20, 2009 3:37 AM
    Edited by: user779842 on Aug 20, 2009 3:55 AM

    I think the only two characters you need to worry about in your comment strings are: ' and & (apostrophe/single quote and ampersand). The latter you can get around by doing:
    set define offbefore running your statements, but the apostrophe you'll have to double up to allow oracle to recognise that it's not the end of the string. Eg:
    I'm a stringwould become
    'I''m a string'  -- NB. this is two single quotes, not 1 double quote!or, if you're on 10g or above, you can use the quote operator (q):
    select q'#I'm a string#' from dual;See the documentation for what characters can be used as the quote delimiters: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_sqltypes.htm#sthref377

Maybe you are looking for

  • Remote and Home Interfaces

    Why do we need a home interface and remote interface for a ejb. Must these interfaces be there for each ejb?

  • Item does not move from Workflow Inbox to Work Item Executed by me

    Hi experts, We have implemented workflow inbox for invoice payment. After archive document in OAWD, we will do posting through Workflow inbox. After posting, the item should go to 'work item executed by me' folder. But the problem is the work item is

  • Some photos missing since Time Machine restore...

    Hi All, I have been looking through the forum to find an answer to this, but I haven't seen anyone else with this exact problem. 2009 iMac, Snow Leopard I had to erase my drive and do a clean install. That went well, and I used Time Machine, and Migr

  • Common Folder for Metadata Templates - Max OSX

    Photoshop CS5 and Bridge CS4 appear to share the same set of metadata templates, whereas Lightroom 3.6 appears to have its own set of metadata templates. Please if there is a way to facilitate sharing the same set of templates among all three apps.

  • My i phone will not turn on

    I was sitting down and i stood up, my iphone 4S fell off of my lap. It fell about 4ft onto a tile floor. Also it was in an Otterbox