Trim between two strings inside a column

Hello,
I have a large data in clob column and string between two values needs to be trimmed to 10 bytes.
ie. - I need to trim string between <Val> and </Val> to 10.
CLOB_COL
<Val>123 Main Street</Val><Addr></Addr><Val>321 Main Street</Val><OtherNode></OtherNode>
And, I would like my result to be:
<Val>123 Main S</Val><Addr></Addr><Val>321 Main S</Val><OtherNode></OtherNode>
What will be the fastest way to update this clob column or probably insert into a new table. (I do not have XML DB installted on this database, so I cannot use XML parser)
Thanks

Hi,
Sorry, I made a mistake.
Try this:
SELECT  REGEXP_REPLACE ( '<Val>2010-10-31 16:59:24</Val>'
                        , '(<Val>[^<]{1,3000})'    || -- \1 = <Val> and up to 3000 characters (not <)
                             '[^<]*'               || -- 0 or more characters (not <) to be removed
                 '(\</Val>)'               -- \2 = </Val>
                        , '\1\2'
                        )     AS val_substring
FROM    dual;A plus-sign in a pattern means the preceding is repeated 1 or more times.
I meant to use an asterisk to mean 0 or more times on this row:
...                          '[^<]*'               || -- 0 or more characters (not <) to be removed
--                     +  was here originally 
By the way, you may have noticed that this site normally doesn't display multiple spaces in a row.
Whenever you post formatted text (including, but not limited to, code) on this site, type these 6 characters:
\(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
This is especially helpful with regular expressions, not only because they're confusing enough with formatting, but because they use brackets which this site may interpret as markup and not print correctly.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • How to add image between two string

    how to add a image between two string .
    example :
    String one <IMG> String two

    grid1 = new GridLayout( 2, 3, 5, 5);
    container = getContentPane();
    container.setLayout(grid1);
    The parameters in GridLayout specifies 2 rows, 3 columns, 5pixels of horizontal gap, 5pixels of vertical gap.
    Did what i could to help, now can somebody help me with JDialog? =(

  • Is there a way to delete text between two strings?

    In Pages, is there a way to delete all text containted between two strings?
    For example, if I have a text document that looks like this:
    String 1
    String 2
    Unwanted text
    Unwanted text
    String 3
    String 4
    Is there was to delete the unwanted text between string 2 and 3 so it looks like this:
    String 1
    String 2
    String 3
    String 4
    The unwanted text is differnet between documents but string 2 and 3 are constant. I want to do this via automator for the same strings on multiple documents.
    Any help is appreciated!

    Do you mean Pages '09 v4.3?
    There were some links here:
    https://discussions.apple.com/message/24051199#24051199
    Peter

  • Return the difference between two strings

    Is it possible to return the difference between two strings?
    For example
    String one = "We went for a walk";
    String two = "We went for a run";
    compare "two" to "one" returns "walk"
    compare "one" to "two" returns "run"I need to return the difference of two strings, one prior to editing and one after editing.
    Then I want to return any difference between the two, which will be the effect of the editing.
    Cheers Alex

    Interesting problem. Before you start writing any code, make up a whole bunch of test case pairs. Decide what the difference between the pairs is. When you start seeing patterns, analyse them. After a while you may have enough data to start writing your program. Here's one test case to get started with:"I saw the cat eat a rat"
    "My cat is hungry"

  • Delete white spaces between two strings

    hi!
    How do I remove white spaces between two strings. I have attached file for reference.
    Thanks
    Attachments:
    untitled4.JPG ‏62 KB

    You first need to define what you consider to be "whitespace". Is it just a space? Is it spaces and linefeeds? What about carriage returns? Tabs? Anything non-alphabetic and/or non-numeric?
    As mentioned previously, the Search and Replace String can be used to delete characters by wiring an empty string to the replace string input. The following, for example, will delete all spaces:
    If you need to delete other whitespace characters, just call it again on the resulting string.
    Message Edited by smercurio_fc on 06-02-2008 09:25 AM
    Attachments:
    Example_VI1.png ‏3 KB

  • How to give relationship between two tables with comon column with between oprator

    Hi Folks,
    I am using Sql Server 2008R2. I am getting a problem to establish relationship between two tables. 
    I have two Tables, 1.Inventory Details Table another one is Inventory Header Table.
    Inventory Details Table having a column Card No and inventory Header Table having columns  From card No and To Card No.
    I want to give relationship between these two tables with Card no. Could you please provide me the Sql Query.
    Your help would be greatly appreciated .
    Regards
    hasthi.
    email:[email protected]

    Hi Raju,
     We have two way that we can relate to the table either join or quality condition use following syntax/Query  for relating two tables 
    select * from Inventory_Details ID inner join  Inventory_Header IH on ID.CardNo between IH.FrmCardno and IH.ToCardNo
    or 
    Select * from  Inventory_Details ID ,Inventory_Header IH where ID.CardNo=IH.CardNo OrSelect * from  Inventory_Details ID ,Inventory_Header IH where ID.CardNo between IH.FrmCardno and IH.ToCardNo
    Hope this will help you 
    Niraj Sevalkar

  • Search and replace string inside a column

    Hi,
    in my table there is Column A with Type NVARCHAR.
    i need to search inside all the rows in that column to find the string "_TH" and remove it wherever it exist.
    how can i do it?

    you can follow below solution .
    Step 1: Create a temporary table to load all the records which are having column with '-TH'
    Step 2 :  Use update statement and join it with temporary table to update the qualified records
    Benefits: This is a set based solution which is optimal and high perfroming
    Script:
    create table test1(col1 nvarchar(20))
    insert into test1 values('one_th'),('two_th'),('Gauri')
    --Create Temporary table
    select * 
    into #tmp2
    from Test1
    where col1 like '%_TH%'
    --update all such rows which are having column with '_TH'
    Note: I am replacing all columns with '_TH' with space . you can replace with other characters based upon your requirement.
    update t
    set col1 = replace(t.col1,'_TH','')
    from test1 t
    inner join #tmp2 t2
    on t.col1 = t2.col1
    Please comment If this solution helps you.

  • How to get difference between two rows for a column field?

    hi, all,
    Could anyone show me what query statement is to get the difference betweem two rows for two column fields?
    The tables and its records are like this:
    id,      begin,      end
    p1         21          30
    p2          45          60
    p3          120          150
    I would like to have the query result like this
    id,    diff
    p1     15    --- which is 45 minus 30
    p2     60    --- which is 120 minus 60
    and so on...
    thank you in advance.
    Raffy

    You can use the LAG function to access values from previous rows:
    with q as (select 'p1' id, 21 v_start, 30 v_end from dual
    union all
    select 'p2', 45, 60 from dual
    union all
    select 'p3', 120, 150 from dual)
    select id, v_start, v_end, v_start - lag (v_end, 1, 0)
      over (order by id) v_diff from q
    ID,V_START,V_END,V_DIFF
    p1,21,30,21
    p2,45,60,15
    p3,120,150,60
    See the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/functions075.htm

  • How to join two columns between two tables with different column names

    Hi
    How i can join 2 columns with different names between the 2 tables.
    Can any one please give solution for this.
    Thanks
    Manu

    Hi,
    basic understanding of joins:
    If you want to join 2 tables there should be matching column w.r.t. data and it's data type. You need not to have same column names in both the tables...
    so, find those columns which has got same values..

  • How to calculate the number of months between two string as yyyymm

    Dear all,
    I have two month string like yyyymm e.g. 201003 -- 201105. Now I want to calculate the number of months bertween these two month string? How can I do that? Thanks.

    888099 wrote:
    Hi,
    Hope this will help :
         public static void main(String[] args) {
              Calendar cal1 = new GregorianCalendar(2010, 02, 01);
              Calendar cal2 = new GregorianCalendar(2011, 04, 01);
              int years = cal1.get(Calendar.YEAR) - cal2.get(Calendar.YEAR);
              int months = cal1.get(Calendar.MONTH) - cal2.get(Calendar.MONTH);
              System.out.println("number of months : "+Math.abs(years*12 + months));
         }Or with only Strings :
         public static void main(String[] args) {
              String s1 = "201002";
              String s2 = "201104";
              int years = Integer.valueOf(s1.substring(0,4)) - Integer.valueOf(s2.substring(0,4));
              int months = Integer.valueOf(s1.substring(4)) - Integer.valueOf(s2.substring(4));
              System.out.println("number of month : "+Math.abs(years*12 + months));
         }Edited by: 888099 on 28 sept. 2011 05:49Full code solutions will not help the OP, he will be back here with a different Date question. Posters here try to nudge the OP to figure out the solution himself.

  • How would I split a string between two strings?

    Hi Guys,
    I have a question hopefully you guys can help with..
    I have a set of data similar to
    sefsfesef<1111>Example<2222>desefsefsefefsefsef<1111>Example2<2222>sefsefsef
    What I want to do is split my string between the <1111> and <2222> and get "Example" and "Example2" back... is this possible in Java? Possibly using regular expressions of sorts. I'm a little lost, any help would be much appreciated!
    Thanks,
    Vasant

    Here is an example (parse.java) that will work provided that the content between <1111> and <2222> does not contain the < character.
    import java.util.regex.*;
    public class parse {
      public static void main(String args[]) {
        String teststring = "sefsfesef<1111>Example<2222>desefsefsefefsefsef<1111>Example2<2222>sefsefsef";
        Pattern p = Pattern.compile("<1111>([^<]*)<2222>");
        Matcher m = p.matcher(teststring);
        while(m.find()) {
          System.out.println(m.group(1));
    }I'm sure some regex guru around here could solve this one in 3 characters or less, but that ain't me :)

  • Calculation date deference between two rows in same column and in same table

    mytable
    accountno
    tdate
    1001
    01/01/2014
    1002
    01/01/2014
    1003
    01/01/2014
    1004
    01/01/2014
    1005
    01/01/2014
    1001
    01/02/2014
    1002
    01/02/2014
    1003
    01/02/2014
    1004
    01/02/2014
    1005
    01/02/2014
    1001
    01/03/2014
    1002
    01/03/2014
    1003
    01/03/2014
    1004
    01/03/2014
    1005
    01/03/2014
    1001
    01/04/2014
    1002
    01/04/2014
    1003
    01/04/2014
    1004
    01/04/2014
    1005
    01/04/2014
    This is my table. I want find out account wise date deference between first date to second date, second date to third date, third date to fourth date, fourth date to fifth date........... Could you please provide me the solution with any SQL, VB or MS access
    query!

    In SQL 2012/2014:
    SELECT accountno, tdate,
           datediff(DAY, LAG(tdate) OVER (PARTITION BY accountno ORDER BY tdate), tdate)
    FROM   tbl
    ORDER  BY account, tdate
    In SQL 2005/2008:
    ; WITH CTE AS (
        SELECT accountno, tdate,
               rowno = row_number OVER (PARTITION BY accountno ORDER BY tdate)
        FROM   tbl
    SELECT a.accoounno, a.tdate, datediff(DAY, b.tdate, atdate)
    FROM   CTE A
    LEFT   JOIN CTE B ON b.accountno = a.accountno
                     AND b.rowno     = a.rowno - 1
    ORDER  BY a.accountno, a.tdate
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to drag and drop an Image between two JPanels inside a Split Pane

    I'm tring to do that, and my actual problem is as follows:
    I drag the Image from the bottomPanel but I can't drop it in the topPanel, I'm using this classes:
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import java.awt.dnd.*;
    import java.awt.datatransfer.*;
    import java.awt.image.*;
    public class MoveableComponentsContainer extends JSplitPane {     
         public DragSource dragSource;
         public DropTarget dropTarget;
    public JPanel topPanel = new JPanel();
    public JPanel bottomPanel = new JPanel();
         public int ancho;
    public int alto;
    public MoveableLabel lab1,lab2,lab3,lab4;
    public Icon ico1, ico2,ico3,ico4;
    private static BufferedImage buffImage = null; //buff image
         private static Point cursorPoint = new Point();
    public int getMaximumDividerLocation() {
    return ( ( int ) ( alto * .85 ) );
    public int getMinimumDividerLocation() {
    return( ( int ) ( alto * .85 ) );
         public MoveableComponentsContainer(int Weight, int Height ) {
    alto = Height;
    ancho = Weight;
    setOrientation( VERTICAL_SPLIT);
    setDividerSize(2);
    getMaximumDividerLocation();
    getMinimumDividerLocation();
    setPreferredSize(new Dimension( (int) ( Weight * .99 ), (int) ( Height * .94 ) ) );
    setDividerLocation( getMaximumDividerLocation() );
    System.out.println( " getDividerLocation() = " + getDividerLocation() );
    topPanel.setName("topPanel");
    bottomPanel.setName("bottomPanel");
    bottomPanel.setPreferredSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .15 ) ) );
    bottomPanel.setMaximumSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .15 ) ) );
    bottomPanel.setMinimumSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .15 ) ) );
    topPanel. setPreferredSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .85 ) ) );
    topPanel. setMaximumSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .85 ) ) );
    topPanel. setMinimumSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .85 ) ) );
    bottomPanel.setEnabled(true);
    bottomPanel.setVisible(true);
    bottomPanel.setBackground( new Color( 57,76,123 ) );
    topPanel. setEnabled(true);
    topPanel. setVisible(true);
    topPanel. setBackground( new Color( 57,76,123 ) );
    setBottomComponent( bottomPanel );
    setTopComponent( topPanel );
    setOneTouchExpandable( false );
    bottomPanel.setBorder(BorderFactory.createTitledBorder("Drag and Drop Test"));
              setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.white, Color.gray));
    bottomPanel.setLayout( new FlowLayout() );
    topPanel.setLayout(new FlowLayout());
              addMoveableComponents();
         private void addMoveableComponents() {
    ico1 = new ImageIcon( "/usr/local/installers/java/lll/DnD/switchm.gif");
    lab1 = new MoveableLabel("Centrales", ico1, topPanel );
    lab1.setName("labelOne");
    bottomPanel.add( lab1 );
              lab2 = new MoveableLabel("Destinos", ico1, topPanel);
    lab2.setName("labelTwo");
              bottomPanel.add( lab2 );
              lab3 = new MoveableLabel("Registros", ico1, topPanel );
    lab3.setName("labelThree");
              bottomPanel.add( lab3 );
              lab4 = new MoveableLabel("Parametros", ico1, topPanel);
    lab4.setName("labelFour");
              bottomPanel.add( lab4 );
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import java.awt.dnd.*;
    import java.awt.datatransfer.*;
    public class MoveableLabel extends JLabel implements Transferable {
    final static int FILE = 0;
    final static int STRING = 1;
    final static int IMAGE = 2;
    DataFlavor flavors[] = { DataFlavor.javaFileListFlavor,
    DataFlavor.stringFlavor,
    DataFlavor.imageFlavor };
    public JPanel PanelDestino;
    public JPanel PanelOrigen;
    public DropTarget dropTarget;
    public DropTargetListener dropTargetLis;
         private static final Border border = BorderFactory.createLineBorder(Color.black, 1);
         public MoveableLabel(String text, Icon ic, JPanel DestPanel) {
              super( text, ic, TRAILING);
    PanelDestino = DestPanel;
              MouseEventForwarder forwarder = new MouseEventForwarder();
              addMouseListener(forwarder);
              addMouseMotionListener(forwarder);
              setBorder(border);
              setBounds(0,0,50,100);
              setOpaque(true);
    setTransferHandler(new TransferHandler("text"));
    setBackground( new Color( 57,76,123 ) );
    public synchronized DataFlavor[] getTransferDataFlavors() {
         return flavors;
    public boolean isDataFlavorSupported(DataFlavor flavor) {
    boolean b = false;
    b |= flavor.equals(flavors[ FILE ]);
    b |= flavor.equals(flavors[STRING]);
    b |= flavor.equals(flavors[ IMAGE]);
    return (b);
    public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, java.io.IOException {
    return this;
         final class MouseEventForwarder extends MouseInputAdapter {
              public void mousePressed(MouseEvent e) {
                   Container parent = getParent();
    Container brother = (Container)PanelDestino;
    System.out.println( "Parent 1 = " + parent.getName() );
    System.out.println( "Destino 1 = " + brother.getName() );
    JComponent c = (JComponent) e.getSource();
    System.out.println( "getsource() = " + c.getName() );
    TransferHandler th = c.getTransferHandler();
    th.exportAsDrag( c, e, TransferHandler.COPY_OR_MOVE );
    dropTarget = getDropTarget();
    System.out.println( "dropTarget.getComponent().getName() = " + dropTarget.getComponent().getName() );
    for ( int a=0; a < parent.getComponentCount(); a++ ) {
    parent.getComponent( a ).setEnabled( false );
    brother.setDropTarget( dropTarget );
    System.out.println( "dropTarget.getComponent().getName() = " + dropTarget.getComponent().getName() );
              public void mouseReleased(MouseEvent e) {
                   Container parent = getParent();
    Container brother = PanelDestino;
    System.out.println( "Parent 2 = " + parent.getName() );
    System.out.println( "Destino 2 = " + PanelDestino.getName() );
    parent.setEnabled( true );
    brother.setEnabled( false );
    for ( int a=0; a < parent.getComponentCount(); a++ ) {
    parent.getComponent( a ).setEnabled( true );
    import java.awt.*;
    import javax.swing.*;
    public class TestDragComponent extends JFrame {
         public TestDragComponent() {
    super("TestDragComponent");
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension dm = new Dimension();
    dm = tk.getScreenSize();
    System.out.println(dm.height);
    System.out.println(dm.width );
    Container cntn = getContentPane();
    cntn.setFont(new Font("Helvetica", Font.PLAIN, 14));
    cntn.add(new MoveableComponentsContainer(dm.width,dm.height));
              pack();
              setVisible(true);
         public static void main(String[] args) {
              new TestDragComponent();

    Ok I found the answer to your problem. If you download the tutorial they have the code there it's in one folder. I hope this helps.
    http://java.sun.com/docs/books/tutorial/

  • Match between two strings of which one may occur often in python

    I get a large swab of output from pacman -Qi. This output is piped using subprocess and converted to a string using str.decode. This all works.
    But then I would like to be able to cut a a block related to one package out of that large swap of output, like this:
    Name : steam
    Version : 1.0.0.25-3
    URL : http://steampowered.com/
    Licenses : custom
    Groups : None
    Provides : None
    Depends On : bash desktop-file-utils hicolor-icon-theme curl dbus
    freetype2 gdk-pixbuf2 ttf-font zenity lib32-libgl
    lib32-gcc-libs lib32-libx11
    Optional Deps : lib32-ati-dri: for open source ATI driver users
    lib32-catalyst-utils: for AMD Catalyst users
    lib32-intel-dri: for open source Intel driver users
    lib32-nouveau-dri: for Nouveau users
    lib32-nvidia-utils: for NVIDIA proprietary blob users
    lib32-flashplugin: for flash video, copy to
    $XDG_DATA_HOME/Steam/ubuntu12_32/plugins/
    Required By : None
    Conflicts With : None
    Replaces : None
    Installed Size : 6424.00 KiB
    Packager : Daniel Wallace <danielwallace at gtmanfred dot com>
    Architecture : x86_64
    Build Date : Fri Feb 8 21:51:42 2013
    Install Date : Mon Feb 11 11:35:09 2013
    Install Reason : Explicitly installed
    Install Script : Yes
    Description : Digital distribution client - open beta - bootstrap package
    The goal is to search the large swab of output for a package installed on a specific install date.
    I've tried many kinds of pattern matching but I cant seem to wrap my head around it. Does anyone know a short, sweet, fast, clean way to do this?
    Greetings
    Last edited by welpert (2013-02-11 16:59:24)

    #!/usr/bin/env python
    # -*- coding: UTF-8 -*-
    import re, sys
    pacman_data = sys.stdin.readlines()
    for line in pacman_data:
    match = re.search( "^install date[ \t]*: (.*)", line, re.I )
    if match: print( match.group( 1 ))

  • How to get the difference between two columns in a column group

    Hi All,
    My first time here and really new to programming. I would like to get the difference between 2 columns that are inside 
    a column group.
    Here is my sample table below: The Column Group is PeriodNumber and can only choose 2. like 1 and 2.. I would like to have a third row which will simply calculate the difference between the amounts in PeriodNumber 1 and 2.
                                PeriodNumber          
    Account                    1                            2     
    1) Cash                10,000                15,000
    2) Receivables      12,000                11,500
    3) Equipment          5,000                  5,500
    Total Assets          27,000                32,000

    Hi yabgestopa,
    From your description, you want to get the difference between two columns in a column group. After testing it in my environment, we can use custom code to achieve your requirement. For more details, you can refer to the following steps:
    Copy the custom code below and paste it to your report. (Right-click report>Report Properties>Code)
    Dim Shared Num1 As Integer
    Dim shared Num2 As Integer
    Public Function GetAmount(Amount as Integer, Type as String)
    If Type = "1" Then
    Num1=Amount
    Else
    Num2=Amount
    End If
    Return Amount
    End Function
    Public Function GetDif()
    Return Num1-Num2
    End function
    Right-click the second column to insert a third column with Outside Group-Right.
    Then use the expressions below in the matrix.
    =Code.GetAmount(Fields!Amount.Value,Fields!PeriodNumber.Value)
    =code.GetAmount(Sum(Fields!Amount.Value),Fields!PeriodNumber.Value)
    =Code.GetDif()
    The report looks like below.
    If you have any questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

Maybe you are looking for

  • I want to install windows 7 on my iMac..

    Ok so ive been thinking about installing windows XP, Vista, or maybe even windows 7 on my iMac. The only problem is, i just got a mac and i dont know too much about it (slowly learning though) and i dont want to overwhelm myself. Ive seen tutorials o

  • How do I recover data from a single App using an iTunes backup and put it back on my iPhone?

    An app I use (Text Me 2) automatically cleared conversation history. I have an iTunes back-up of it from last year. I tried searching a ton and found articles, but never found a step-by-step article from start to finish describing how I can get only

  • LCD TV connection

    My B&O TV manual tells me I need to connect my PC via a DVI-I connector on the TV. Can anyone advise a cable spec. for this job.

  • TSV_TNEW_PAGE_ALLOC_FAILED when start export BSEG data

    Dear all, We need to download contents of database table BSEG into a local file via SAP GUI. When we start we get TSV_TNEW_PAGE_ALLOC_FAILED. SAP ECC 6.0 Oracle 10.2.0.2 and HP-UX 11.23 There is physical memory in the system of 50 GB. SAP Memory     

  • Generate a SQL "IN" clause using ALDSP

    Problem Summary ALDSP: Generate a SQL "IN" clause Problem Description I would like to know if there is a possibility of generating an SQL "IN" clause using ALDSP. I would need the XQuery construct to create an SQLsomething like- select * from emp whe