Truncate RTF character in varchar2 field

Hi everyone.
I have a varchar2 field in a table on Oracle 10g. I need to cut all RTF characters from the data that is stored in
this field and only extract the simple text without any format.
Is there any way or a SQL function to eliminate those characters and retrive only the simple text in a Query?
or
Do I need to develop a special procedure in Oracle or in any Language in order to do that proccess ?
Thanks.
Andres.

Tables don't have 'fields'.
So what you need to do in your 3GL program I do not know.
People using Oracle, with probably apply regexp_replace on that column.
Sybrand Bakker
Senior Oracle DBA

Similar Messages

  • Problem with 'order by' and comparison operator with varchar2 field

    I have a problem with the following sql query (field1 is varchar2):
    SELECT field1
    FROM tablename
    WHERE field1 > 'AA10BB'
    ORDER BY field1
    The contents of field1 is:
    AA10BB
    AA10-10BB
    AA10-12BB
    The sql query without the WHERE clause sorts field1 this way:
    AA10BB
    AA10-10BB
    AA10-12BB
    But the sql query with the WHERE clause has no hits.
    It seems that when sorting the minus character is greater than the 'B' character and
    at the comparison ( > 'AA10BB' ) the minus character is lower than the 'B' character!
    The database and client NLS_PARAMTER are GERMAN_GERMANY.
    The database is 9.2.0.7
    Has anyone an idea?

    thanks for your fast reply!
    My problem was that NLS_SORT was set to 'GERMAN' and NLS_COMP to 'BINARY'.
    NLS_SORT = GERMAN orders the varchar2 fields in form of 'a A b B ... 0 1 2 3 ..'
    NLS_COMP = BINARY compares binary (ASCII-Table).
    I use now:
    SELECT field1
    FROM tablename
    WHERE field1 > 'AA10BB'
    ORDER BY NLSSORT(field1, 'NLS_SORT = Binary'');

  • How to get a subset of text from a varchar2 field

    Hello.  I am trying to select a subset of text from a varchar2 field.  This is login information from dba_audit_trail view.  Here's an example of the field (comment_text from dba_audit_trail):
    Authenticated by: DIRECTORY PASSWORD;EXTERNAL NAME: cn=orcladmin,cn=Users,dc=idacorp,dc=local; Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=555.555.555.555)(PORT=99999))
    I am trying to just select the "orcladmin" text - i.e. everything after the first "=" up to the first ","
    I can get everything after the first "=" with this:
    select substr(comment_text, instr(comment_text, '=') + 1) from dba_audit_trail
    ... but I don't know how to stop at the first ","
    Any help would be greatly appreciated.
    Thanks!
    Message was edited by: DRC

    Hi,
    Here's one way to do it:
    WITH got_pos    AS
        SELECT  comment_text    -- and whatever other columns you need
        ,       INSTR (cooment_text, '=')   AS equal_pos
        ,       INSTR (cooment_text, ',')   AS comma_pos
        FROM    dba_auit_trail
        WHERE   ...             -- any filtering goes here
    SELECT  SUBSTR ( comment_text
                   , equal_pos + 1
                   , comma_pos - (equal_pos + 1)
                   )   AS first_cn
    FROM    got_pos
    You could do it without a sub-query; you'd just have to do the exact same INSTR 2 times, where I used equal_pos 2 times.
    You could also get the results you want using regular expressions, such as:
    SELECT  REGEXP_SUBSTR ( comment_text
                          , '=([^,]*),'
                          , 1
                          , 1
                          , NULL
                          , 1
                          )      AS first_cn
    FROM    dba_audit_trail
    Although this uses less code, it's slower than using INSTR and SUBSTR .

  • How to stor special characters in a VARCHAR2 field?

    I am trying to store a encrypted string into a 'varchar2' field. But, the encrypted string is not stored properly. Some characters are stored incorrectly.
    Can anybody help me in storing an encrypted string into a varchar2 field??

    HTH
    Laurent Schneider
    OCM DBA
    SQL> select * from z;
    S
    Mama?Mia
    a b c
    123
    SQL> select * from z where translate(s,'~ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz1234567890','~') is not null;
    S
    Mama?Mia
    SQL> select * from z where regexp_like(s, '[^[:alnum:][:space:]]');
    S
    Mama?Mia

  • Sorting a varchar2 field in Report 10g

    Dear all,
    i have a table of salaries, which have a field RANK_NO VARACHAR2.
    I create a report and order it by RANK_NO. but it is not ordering what i want to be. it is ordered like
    1
    10
    11
    2
    3
    4
    5
    6
    7
    8
    9
    then i use the order by cluase like this,
    ORDER BY TO_NUMBER(REGEXP_SUBSTR(RANK_NO,'[0-9]+')),
    REGEXP_SUBSTR(UPPER(RANK_NO),'[A-Z]+').
    but the result is same .
    how to sort a varchar2 field in reports?
    Thanks & Regards

    Hi Muhammad,
    Use the following Order By clause hope it helps you,
    ORDER BY TO_NUMBER (REPLACE (RANK_NO, LTRIM (RANK_NO, '0123456789'))), RANK_NO
    Best Regards
    Arif Khadas

  • To insert single quote in a varchar2 field

    hi guys,
    i am facing a simple problem, can any one of you help me in this regard. the problem is i am unable to insert a single quote in a varchar2 field like
    SQL> DESC EMP
    Name Null? Type
    EMPNO NOT NULL NUMBER(4)
    ENAME VARCHAR2(10)
    JOB VARCHAR2(9)
    MGR NUMBER(4)
    HIREDATE DATE
    SAL NUMBER(7,2)
    COMM NUMBER(7,2)
    DEPTNO NUMBER(2)
    SQL> INSERT INTO EMP (EMPNO, ENAME) VALUES (100, 'Mc'Aure') ;
    ERROR:
    ORA-01756: quoted string not properly terminated
    oracle takes ' as the delimiters for identifying the word. in my case the name itself contains a single quote which is to be inserted. how to insert the single quote
    i want to insert it from asp coding and also from sql plus 8.0.
    advanced thanks
    ananth

    If you use a ' in a varchar2, it must be marked with a second '.
    In your case:
    SQL> INSERT INTO EMP (EMPNO, ENAME) VALUES
    (100, 'Mc''Aure') ;
    null

  • Convert varchar2 field into date formatted: DD-MON-YYYY

    Thanks in advance for anyone's help on this matter as I know it takes your time and expertise. I am pretty new to SQL but learning my way through it just have an issue with a text to date field conversion. It is an Oracle 10g database and I am writing in SQL. There is a field called Demand which is formatted in varchar2 format of ddmmyy. There is also a field that is formatted as a date called Payment which is formatted as DD-MON-YYYY.
    Essentially I need to do a simple Payment >= Demand, however as you can see that is some issue with that being a varchar2 field. Does anyone know if it is possible to do that type of expression against those two fields. Was thinking about possibly converting the varchar2 to a date but not sure how to get to that DD-MON-YYYY format.
    Also there are situations where this Demand field will often times be null as it would have never recieved any outbound correspondence in the past and would not have a date at all.
    Thanks
    Edited by: user10860766 on Aug 18, 2009 8:14 AM
    Edited by: user10860766 on Aug 18, 2009 8:19 AM

    Hi,
    It's hard to detect bad dates in pure SQL, especially if you need to be precise about when February 29 is valid.
    It's easy with a user-define function, like the one in [this thread|http://forums.oracle.com/forums/thread.jspa?messageID=3669932&#3669932].
    Edited by: Frank Kulash on Aug 18, 2009 3:50 PM
    To create a stand-alone function:
    CREATE OR REPLACE FUNCTION     to_dt
    (     in_txt          IN     VARCHAR2                    -- to be converted
    ,     in_fmt_txt     IN     VARCHAR2     DEFAULT     'DD-MON-YYYY'     -- optional format
    ,     in_err_dt     IN     DATE          DEFAULT     NULL
    RETURN DATE
    DETERMINISTIC
    AS
    BEGIN
         -- Try to convert in_txt to a DATE.  If it works, fine.
         RETURN     TO_DATE (in_txt, in_fmt_txt);
    EXCEPTION     -- If TO_DATE caused an error, then this is not a valid DATE: return in_err_dt
         WHEN OTHERS
         THEN
              RETURN in_err_dt;
    END     to_dt
    /To use it:
    SELECT  primary_key  -- and/or other columns to identify the row
    ,       demand
    FROM    table_x
    WHERE   demand          IS NOT NULL
    AND     to_dt ( demand
               , 'DDMMYY'
               )          IS NULL;

  • Output a varchar2 field to a spool file.

    I have a varchar2 field in the database which has returns in it. So it has 3 lines of output. When I spool this to s file, that record spans across 3 lines as opposed to 1 line/record.
    I tried using replace(field,'^M','') to get the output but that gives me only the first line of the field.......
    ANY IDEAS ?????

    Have you checked the width of varchar2 data type.else modify it to long and try it.

  • Delphi 4 can not move a string to VARCHAR2 field

    Hi,
    I'm using Oracle 8 version 8.0.4.0.0 and Delphi 4. I can not move a string data (20 characters) over VARCHAR2 field, so I'm also using the BDE (5.11) and ODBC to do this. The message sent by Delphi is 'Operation not applicable'.
    TIA,
    Roberto.

    Hi,
    I'm using Oracle 8 version 8.0.4.0.0 and Delphi 4. I can not move a string data (20 characters) over VARCHAR2 field, so I'm also using the BDE (5.11) and ODBC to do this. The message sent by Delphi is 'Operation not applicable'.
    TIA,
    Roberto.

  • How to retrieve only the text from a multiline Varchar2 field?

    Dear Friends,
    I have a text in a varchar2 field having text only in line2.
    I want to retrieve the text only skipping the blank line.
    The syntax REPLACE(FIELD_NAME,CHR(10),'') is not working.
    Please help me.
    Thanking you,
    With Regards
    Franklin

    there must be other characters in your text field that are not chr(10) (line feeds etc).
    use a regular expression to replace all the non-printable characters:
    select regexp_replace(field_name,'[^[:print:]]') from table

  • How to find the original lengh of a VARCHAR2 field

    Hi all...
    How to find the original lengh of a VARCHAR2 field. If i use, length function, it is
    giving the length of the feild, not the orginal length of field value.
    How to find the actual length of the field.
    Thanks in advance
    pal

    > How to find the original lengh of a VARCHAR2 field.
    Why?
    And where? A varchar2 in SQL or a varchar2 in PL/SQL? Varchar2 arguments have no explicit size in parameter signature for a procedure or a function.

  • Description on search help field get truncated by it input enable field

    Hi expert,
    I'm facing one problem, description of the fields on the search help dialog screen gets truncated by it own input fields. I want that full description of the fields should appear on the screen. what i need to do for that.

    my friend  ...  you are    refferning the field  in your program from the  field of   Ztable which  you have created  ....
    please  check the field  lable  and change it as  40  lenght in the  field label  give the   full  descrition  activate it  ...
    so that your problem will be solved ..
    see  for example  .
    i write  a  program in that  i use  parameter   declaration as
    tables :  pa0001 .
    parameters : d_pernr like pa0001-pernr.
    then in the MENU path   GOTO-TEXT ELEMENT   -> select the check  box from the dictionary ...
    it was  refferencing the field of  Long text  only  ....
    only thing  is we have  maintian the long text as 40 length and  descrition as what you want .
    reward  points if it is usefulll ,....
    Girish

  • Inserting a varchar2 field with symbols

    I have a varchar2 field and field that I am inserting has symbol in it, Oracal is converting it to a ? when I updated the field.
    ex: '. TESTMEDICINE'
    Do I have to define any thing different in the database or simply oracle can not support the symbols.
    Thank you.

    If you have access to the query generating the data, I would create the correct value there like this:
    regexp_replace( column_name, '[[:digit:]]', '' )
    If you must do it in the query, try using the XPath translate function:
    http://www.w3schools.com/Xpath/xpath_functions.asp#string
    translate( ELEMENT_NAME, '0123456789, '' )
    VARCHAR2 is a variable length text data type. See here:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm
    Kurz

  • How to truncate the first character of a field

    Hi Experts,
             I have a field say X which is having 3 characters say '123'. Now i have to pass only the last 2 values of X to another field Y. that is Y should contain only '23'. Can you please suggest the method to do it.
    Regards,
    Buvana

    Hi,
    You need to use as follows
    var = var+1(2).
    var = var+n(m)
    This means Read two(M) charachter(s) leaving the first one (N)character(s).
    Regards,
    Sesh

  • Cannot insert Chinese character into nvarchar2 field

    I have tested in two environments:
    1. Database Character Set: ZHS16CGB231280
    National Character Set: AL16UTF8
    If the field type of datatable is varchar2 or nvarchar2, the provider can read and write Chinese correctly.
    2. Database Character Set:WE8MSWIN1252
    National Character Set: AL16UTF8
    The provider can not read and write Chinese correctly even the field type of datatable is nvarchar2
    I find that for the second one, both MS .NET Managed Provider for Oracle and Oracle Managed Data Provider cannot read and write NCHAR or NVARCHAR2 fields. The data inserted into these fields become question marks.
    Even if I changed the NLS_LANG registry to SIMPLIFIED CHINESE_CHINA.ZHS16CGB231280, the result is the same.
    For the second situation, only after I change the Database Character Set to ZHS16CGB231280 with ALTER DATABASE CHARACTER SET statement, can I insert Chinese correctly.
    Does any know why I cannot insert Chinese characters into Unicode fields when the Database Character Set is WE8MSWIN1252? Thanks.
    Regards,
    Jason

    Hi Jason,
    First of all, I am not familiar with MS .NET Managed Provider for Oracle or Oracle Managed Data Provider.
    How did you insert these Simplified Chinese characters into the NVARCHAR2 column ? Are they hardcoded as string literals as part of the SQL INSERT statement ? If so, this could be because, all SQL statements are converted into the database character set before they are parsed by the SQL engine; hence these Chinese characters would be lost if your db character set was WE8MSWIN1252 but not when it was ZHS16CGB231280.
    Two workarounds, both involved the removal of hardcoding chinese characters.
    1. Rewrite your string literal using the SQL function UNISTR().
    2. Use bind variables instead of text literals in the SQL.
    Thanks
    Nat

Maybe you are looking for