Preserve single quote in text data.

I have text data that is read into a BurrefedReader, some text contain single quoutes such as Ray's. When I retieve the data instead of seeing the single quote I see a square box replacing the single quote. What can I do in java to preserve the single quote?
Thanks.

Many thanks....here is my original code:
public static String ClobToString(Clob cl) throws IOException, SQLException
if (cl == null)
return "";
StringBuffer strOut = new StringBuffer();
String aux;
String aux2;
BufferedReader br = new BufferedReader(cl.getCharacterStream());
String ls =System.getProperty("line.separator");
while ((aux=br.readLine())!=null)
strOut.append(aux+ls);
return strOut.toString();
Here is the code with the encoding convertion:
public static String ClobToString(Clob cl) throws IOException, SQLException
if (cl == null)
return "";
StringBuffer strOut = new StringBuffer();
String aux;
String aux2;
BufferedReader br = new BufferedReader(cl.getCharacterStream());
String ls =System.getProperty("line.separator");
while ((aux=br.readLine())!=null)
strOut.append(aux+ls);
StringInputStream st = new StringInputStream(strOut.toString());
InputStreamReader inStreamReader=new InputStreamReader(st,"UTF-8");
BufferedReader bufReader=new BufferedReader(inStreamReader);
StringBuffer strOut2 = new StringBuffer();
while ((aux2=bufReader.readLine())!=null)
strOut2.append(aux2+ls);
return strOut2.toString();
I do thank you again for any help.

Similar Messages

  • Preserving Single Quotes

    I'm using the following code to produce a list of zipcodes
    for a radius search:
    <cfset Caller.passedreturneddata =
    Caller.passedreturneddata & "'#mystruct.zipcode[x]#' or ">
    The result is like '12345' or '23456' or '34567'.
    CF is turning the single quotes into double quotes and giving
    SQL error below. How can I preserve the single quotes?
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC
    Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error
    (missing operator) in query expression &apos;fee = No And
    Category = Horoscope And Subcategory = Horoscope3 And ZipCode =
    &apos;&apos;80212&apos;&apos; or
    &apos;&apos;80212&apos;&apos; or
    &apos;&apos;80212&apos;&apos; or
    &apos;&apos;80034&apos;&apos; or
    &apos;&apos;80214&apos;&apos; or
    &apos;&apos;80214&apos;&apos; or
    &apos;&apos;80214&apos;&apos; or
    &apos;&apos;80214&apos;&apos; or
    &apos;&apos;80211&apos;&apos; or
    &apos;&apos;80033&apos;&apos; or
    &apos;&apos;80033&apos;&apos; or
    &apos;&apos;80033&apos;&apos; or
    &apos;&apos;80001&apos;&apos; or
    &apos;&apos;80002&apos;&apos; or&apos;.
    The error occurred in eventsradius.cfm: line 8
    6 : And Category = #form.category#
    7 : And Subcategory = #form.subcategory#
    8 : And ZipCode = #form.zipcode#
    9 : Order by date, time
    10 : </cfquery>
    SQL Select * From Calendar2 Where fee = No And Category =
    Horoscope And Subcategory = Horoscope3 And ZipCode = ''80212'' or
    ''80212'' or ''80212'' or ''80034'' or ''80214'' or ''80214'' or
    ''80214'' or ''80214'' or ''80211'' or ''80033'' or ''80033'' or
    ''80033'' or ''80001'' or ''80002'' or ''80002'' or ''80002'' or
    ''80204'' or ''80295'' or ''80257'' or ''80266'' or ''80266'' or
    ''80248'' or ''80217'' or ''80265'' or ''80292'' or ''80215'' or
    ''80215'' or ''80215'' or ''80255'' or Order by date, time
    DATASOURCE normmy_denver
    VENDORERRORCODE -3100
    SQLSTATE 42000
    Thanks!
    David

    That worked for the single quotes, but I've never seen this
    error before. Not finding anything in Google either.
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC
    Socket][Microsoft][ODBC Microsoft Access Driver] In operator
    without () in query expression &apos;fee = No And Category =
    Horoscope And Subcategory = Horoscope3 And ZipCode IN
    Select * From Calendar2 Where fee = No And Category =
    Horoscope And Subcategory = Horoscope3 And ZipCode IN ''80212','
    80212',' 80212',' 80034',' 80214',' 80214',' 80214',' 80214','
    80211',' 80033',' 80033',' 80033',' 80001',' 80002',' 80002','
    80002',' 80204',' 80295',' 80257',' 80266',' 80266',' 80248','
    80217',' 80265',' 80292',' 80215',' 80215',' 80215',' 80255',' ''
    Order by date, time

  • How to put single quotes around selected data

    Is there a way to return selected column value with single quotes around it?
    Example I have a table:
    select name from test_table;
    returns: George Clooney
    I want it to return 'George Clooney'
    I tried: select '''||name||''' from test_table;
    returns: '||name||'

    ...or
    SCOTT@demo102> select chr(39)||ename||chr(39) from emp;
    CHR(39)||ENA
    'SMITH'
    'ALLEN'
    'WARD'
    'JONES'
    'MARTIN'
    'BLAKE'
    'CLARK'
    'SCOTT'
    'KING'
    'TURNER'
    'ADAMS'Nicolas.

  • Put single quote around input data

    Hi all,
    DB:10G
    Have an input field (P10_item) with text value . Sometimes it can be multiple text values separated by , like T-123,T-870 . sometimes it only has 1 text value.
    How do I construct a query that can take the item and convert the input value to the following example ? By using length function I can find out how many check no in the field but am lost in how to put the ' around each check no. Help
    ex:
    select * from payment where checkno in ('T-123','T-870')
    thanks

    with  t as
    (select 'T-123,T-870'  txt from dual )
    select replace(regexp_replace(txt,'(.+)','''\1'''),',',''',''')from t;
    'T-123','T-870'sorry I did not understand what you wanted at first.
    this shoud break p_10_item into multiple entries if it has commas in it and
    then you can join it to the payment table.
    WITH t AS (SELECT 'T-123,T-870' p_10_item FROM DUAL),
         t2
            AS (    SELECT REGEXP_SUBSTR (p_10_item,
                                          '[^\,]+',
                                          1,
                                          LEVEL)
                              checkno
                      FROM t
                CONNECT BY LEVEL <=
                                LENGTH (p_10_item)
                              - LENGTH (REPLACE (p_10_item, ','))
                              + 1)
    SELECT payment.*
      FROM payment, t2
    WHERE t2.checkno = payment.checknoEdited by: pollywog on May 18, 2011 1:14 PM

  • Single quote in dynamic query

    Hi all;
    Can u please help me on the following dynamic query code ? I know I am missing the single quote around 2 dates but could not figure out where to put it ! I have tried putting 2 or 3 quotes around 2 bind vars but to no avail.
    Want to create a dynamic query to simulate the the following:
    select
    EMPNO,ENAME,JOB,MGR,HIREDATE from emp where HIREDATE >= to_date('01/01/1981','MM/DD/YYYY') and HIREDATE <= to_date('12/31/1982','MM/DD/YYYY');
    dynamic code:
    declare
    v_q varchar2(4000);
    begin
    v_q :='select EMPNO,ENAME,JOB,MGR,HIREDATE from emp ';
    V_q := V_Q
    || 'where HIREDATE >= '
    || 'to_date(' || :P_DATE1 || ',' ||'''MM/DD/YYYY''' || ' )'
    || 'and HIREDATE <= '
    || 'to_date(' || :P_DATE2 || ',' ||'''MM/DD/YYYY''' || ' )';
    -- end the sql
    v_q := v_q ||';';
    dbms_output.put_line ('V_Q is ' || V_Q);
    end;
    Thanks.
    Zen

    declare
        v_q varchar2(4000);
        v_rec emp%rowtype;
        v_cur sys_refcursor;
    begin
        v_q :='select EMPNO,ENAME,JOB,MGR,HIREDATE from emp ';
        V_q := V_Q  || 'where HIREDATE >= to_date(:P_DATE1,''MM/DD/YYYY'') and HIREDATE <= to_date(:P_DATE2,''MM/DD/YYYY'')';
        dbms_output.put_line ('V_Q is ' || V_Q);
        open v_cur
          for v_q
          using '01/01/1981',
                '12/31/1982';
        loop
          fetch v_cur
            into v_rec.empno,
                 v_rec.ename,
                 v_rec.job,
                 v_rec.mgr,
                 v_rec.hiredate;
          exit when v_cur%notfound;
          dbms_output.put_line('empno = ' || v_rec.empno);
          dbms_output.put_line('ename = ' || v_rec.ename);
          dbms_output.put_line('job = ' || v_rec.job);
          dbms_output.put_line('mgr = ' || v_rec.mgr);
          dbms_output.put_line('hiredate = ' || to_char(v_rec.hiredate,'MM/DD/YYYY'));
          dbms_output.put_line('====================');
        end loop;
        close v_cur;
    end;
    V_Q is select EMPNO,ENAME,JOB,MGR,HIREDATE from emp where HIREDATE >=
    to_date(:P_DATE1,'MM/DD/YYYY') and HIREDATE <= to_date(:P_DATE2,'MM/DD/YYYY')
    empno = 7499
    ename = ALLEN
    job = SALESMAN
    mgr = 7698
    hiredate = 02/20/1981
    ====================
    empno = 7521
    ename = WARD
    job = SALESMAN
    mgr = 7698
    hiredate = 02/22/1981
    ====================
    empno = 7566
    ename = JONES
    job = MANAGER
    mgr = 7839
    hiredate = 04/02/1981
    ====================
    empno = 7654
    ename = MARTIN
    job = SALESMAN
    mgr = 7698
    hiredate = 09/28/1981
    ====================
    empno = 7698
    ename = BLAKE
    job = MANAGER
    mgr = 7839
    hiredate = 05/01/1981
    ====================
    empno = 7782
    ename = CLARK
    job = MANAGER
    mgr = 7839
    hiredate = 06/09/1981
    ====================
    empno = 7839
    ename = KING
    job = PRESIDENT
    mgr =
    hiredate = 11/17/1981
    ====================
    empno = 7844
    ename = TURNER
    job = SALESMAN
    mgr = 7698
    hiredate = 09/08/1981
    ====================
    empno = 7900
    ename = JAMES
    job = CLERK
    mgr = 7698
    hiredate = 12/03/1981
    ====================
    empno = 7902
    ename = FORD
    job = ANALYST
    mgr = 7566
    hiredate = 12/03/1981
    ====================
    empno = 7934
    ename = MILLER
    job = CLERK
    mgr = 7782
    hiredate = 01/23/1982
    ====================
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Single quote used with in text data renders to inalid display

    I have the following text snipit that is coming from an Oracle database column: ...did not include 'special decontamination'. New ...
    I am putting this into a pretty standard text object.  When the report is previewed and subsequently printed as a PDF each single quote is transformed to the text string &_#_3_9_; code (without the underscores). This also occurs for quotation marks appearing as &_q_u_o_t_; and ampersands appearing as &_;_a_m_p_;
    I've tried changing the text interpretation property from none to rtf and, with a refresh, nothing changed.  It is hard for me to believe that no one else has seen this but since you can not search the forum for this string (as it converts it to the single quote) may not one has asked.
    Thanks in advance.

    Hi Don,
    The CLOB would do it. 
    Not sure there is a way around this aside from how you've already been dealing with it. 
    To simply your formula a bit, you don't need to do a loop just have it check for each of the tags like:
    stringVar TempText := {PPR_Main.CONCERNS};
    TempText := Replace (TempText, '&_#_3_9_;', "'") ;
    TempText := Replace (TempText, '&_;_a_m_p_', "&") ;
    TempText := Replace (TempText, '&_q_u_o_t_;', '"') ;
    TempText
    I agree though that there may be other tags added later on based on other characters so it could be infinite.  Try the common characters like Exclamation and Question marks. 
    Good luck,
    Brian

  • SQL*Loader and data enclosed by single quotes

    Hello,
    I need to migrate some data from Sybase to Oracle. Can't use the Migration Workbench because this is Sybase's SQL Anywhere product. We are therefore trying to load via SQL*Loader.
    Sybase outputs its data into text files and encloses it with single quotes, like:
    'ABC123',
    'UR94LL',
    '7YUHII'
    We are running into a problem because we cannot figure out how to use the OPTIONALLY ENCLOSED BY parameter with single quotes. If we just use the FIELDS TERMINATED BY parameter, then the entire string, including the quotation marks, gets loaded into the Oracle table. This causes bad records to be created when the data is exactly the length of the column width - the two quotation markss make the field longer than is allowed in the table. Plus - the data shouldn't have quotes around it in normal situations.
    We can do 'Find and Replace' to replace the single quotation marks with double quotations, but some of the Sybase tables are huge, and we'd like to avoid having to open and edit them. However, if this is the only way to go, then we'll have to use it. I just wondered whether anyone had run into this before and been able to solve it.
    Thanks.
    -melissa

    We are running into a problem because we cannot figure out how to use the OPTIONALLY ENCLOSED BY parameter with single quotesTry
    OPTIONALLY ENCLOSED BY X'27'http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96652/ch06.htm#1015083

  • Text within single quotes

    Hello Everybody,
    I have a requirement wherein i need to take out text which exists within single quotes.
    For eg:
    string1 = Hi ' I am within single quotes' .
    here i need to take the text which is inside single quotes aside.
    Kindly provide me a solution.
    Thanks and Regards
    Manish

    Use SPLIT.
    TYPES: BEGIN OF ITAB_TYPE,
            WORD(20),
          END   OF ITAB_TYPE.
    DATA: ITAB TYPE STANDARD TABLE OF ITAB_TYPE WITH
                    NON-UNIQUE DEFAULT KEY INITIAL SIZE 5.
    SPLIT 'Hi '' I am within single quotes''' AT '''' INTO TABLE ITAB.
    So you will have the entire string in the second record of the table.
    Note that working with single quotes in ABAP makes you use twice single quotes, in order to avoid ending the string.
    Message was edited by:
            Angel Garcia

  • Can we have a Single quote in the tooltip text?

    Hi,
    We have some tooltips for the presentation columns which contains a single quote.
    When I try to view the tooltip from answers the single quote is being replaced by double quotes.
    I tried to use all sorts of escape characters for single quote, like "\'" and ''' and "'" but that didn't work.
    Is there any way to do this.
    Thanks!!
    Vasantha.P

    As I said in my earlier post, I am looking for the tooltips for the Presentation tables and columns. The tooltips for these were extracted from the RPD using the externalize Strings option and these externalized strings are stored in the database.
    So I am escaping the single using a single quote both in rpd and in the database.
    Example text I have used both in the rpd and database is something like "Shipment's start time". I tried with "Shipment''s start time", " Shipment'''s start time", but it didn't work.
    Thanks!!
    Vasantha.P

  • 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.

  • URGENT  update a table with a text that has a single quote in it

    Hello, I am trying to update a table with a text that has a single quote in it. I believe I need to use two singles quotes but I am not sure how.
    For example:
    UPDATE TEST
    SET DESCRLONG='Aux fins d'exportations'
    WHERE etc...
    Should I put 2 singles quotes before the quote in the text?
    UPDATE TEST
    SET DESCRLONG='Aux fins d'''exportations'
    WHERE etc...
    Thank you very much :)

    The best way depends on the version of Oracle.
    But, the quick and universal answer is to use two single quotes
    SQL> connect test/test
    Connected.
    SQL> create table test (descrlong varchar2(128));
    Table created.
    SQL> insert into test values ('This is a string with a '' single quote');
    1 row created.
    SQL> select * from test;
    DESCRLONG
    This is a string with a ' single quote
    SQL> update test set descrlong='Aux fins d''exportations'
      2  where descrlong like 'T%';
    1 row updated.
    SQL> select * from test;
    DESCRLONG
    Aux fins d'exportations
    SQL>                                             

  • Data model: single quote in default parameter value

    Hello,
    when I assign a default value to a parameter in my Data model, which includes a single quote (i.e. "It's a default value"), then the single quote is escaped with a backslash (i.e. "It\'s a default value") when I open the report associated with the data model. How can I get rid of the escape character when opening a report?
    Regards,
    Jure

    Hi Yogini,
    Thanks for your reply.
    When the customer name is selected, discoverer reports automatically enclose the customer names in single quotes. like 'ABC LTD', 'ABC's INC',
    I know how to change this single quote format. Also we don't want user to change the parameter selection criteria once selected.
    Also related to double quotes isn't it doubles are treated as column names in the SQL query and can not be used for any other purpose.
    Apologies, I haven't tried this but I think it will not work. Have you tried this with discoverer viewer.
    As mentioned intrusting things is when a customer name with single quote is selected in discoverer Plus it automatically formats the filter criteria to look like ['ABC LTD', 'ABC''s INC'] but this thing doesn't happen in viewer.
    I think this is a bug in discoverer viewer and think there must be some patch available to correct this problem.
    Sorry, don't have a solution yet but will certainly update the thread once I get the solution.
    Also please keep looking for a solution and let me know as well.
    Thanks a lot in advance.
    Best Regards,
    Manish

  • How to make search string for the searched text containing single quote?

    Hi all,
    When trying to search some Contacts from Eloqua, I have to make a search string which would list out some specified EmailAddress.
    Unfortunately, I meet several emails who have single quote in their spelling.
    I got 'invalid format' error when both using them directly and making single quote twice.
    Any suggestions?
    Thanks,
    Biao

    When testing, the following examples:
    GET /Api/rest/1.0/data/contacts?search=emailAddress=bm'[email protected]
    GET /Api/rest/1.0/data/contacts?search='emailAddress=bm'[email protected]'
    GET /Api/rest/1.0/data/contacts?search=emailAddress="bm'[email protected]"
    GET /Api/rest/1.0/data/contacts?search="emailAddress=bm'[email protected]"
    All return:
      "elements":
        "type":"Contact",
        "id":"1421620",
        "createdAt":"1419611518",
        "depth":"minimal",
        "name":"bm'[email protected]",
        "updatedAt":"1419611519",
        "emailAddress":"bm'[email protected]"
      "page":1,
      "pageSize":1000,
      "total":1
    Likewise, the following returns nothing:
    GET /Api/rest/1.0/data/contacts?search=emailAddress='bm'[email protected]'
    Hopefully this helps,
    Bojan

  • Sharepoint 2013, Document Library: Sharepoint is changing data in a single line of text column to ISO8601 after modifying other columns

    Hello there,
    basically, as the title says: We have a Document Library on a Sharepoint 2013. Attached to every document are multiple columns, the type for every column is 'Single line of text'.
    One column is called 'billing date' and has suitable data in it, e.g. 01.01.2015, 26.02.2015, 29.03.2015 an so on.
    Sometimes when someone is editing an other column of the same document the data in 'billing date' changes from 01.01.2015 to 2015-01-01T00:00:00Z for that document, seemingly randomly.
    Is there any way to configure or prevent this?
    Thanks in advance and kind regards,
    Michael

    Hi,
    From your description, my understanding is that SharePoint changes the format of date in single line.
    It is very strange issue. I try to reproduce your issue in my environment, but everything is OK.
    To solve your issue, I need to collect some information, please confirm these points below:
    When will the format of date change? Does it change immediately when you edit the document or after clicking save button?
    Does the issue occur in this document library or each one in your environment?
    Do you have some special configurations for this document library?
    In addition, could you provide a screenshot as below?
    Best Regards,
    Vincent Han
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • How to print long raw text data in report output in single line?

    Hi All,
    I have a requirement where I need to print raw comma separated text data in the report output which end user will open in excel and can sort as required. I can not directly generate excel output.
    Now there is huge set of data and each row from the report query should be get printed on single line, It should not get printed on the next line.
    I tried to extending the report with 240 characters but still there are some text data which is getting printed on the next line.
    Please share your view if someone has any solution on this issue.
    Thanks in Advance.
    Arun

    Make the report even wider. By default a report layout can be 10 pages wide. If you need more, change the "Max. Horizontal Body Pages" property, and extend your layout too.
    IMHO, I wouldn't even use Reports to create a csv file. Utl_file or an sqlplus script that spools to a file are better options I think.

Maybe you are looking for