0

I have a column which contains a string within this string their is a GUID see below called voucherID, I would like to replace this GUID from another column on the same row.

<VoucherID>6c1c5c4f-3bab-4804-9a92-80b34f448cfe<VoucherID>

any help appreciated.

There are around 6000 rows.

2
  • 1
    Is the GUID to be replaced different on each row or the same? And what RDBMS are you using? Commented Nov 6, 2011 at 10:50
  • What datatype (and name) is your column that holds the XML-enclosed GUID ?? Commented Nov 6, 2011 at 16:56

2 Answers 2

1

IF on Oracle try

UPDATE YourTable T SET
T.YourXMLColumn = SUBSTR ( T.YourXMLColumn, 1, INSTR ( T.YourXMLColumn, '>' ) + 1 ) || 
                  T.YourValueColumn || 
                  SUBSTR ( T.YourXMLColumn, INSTR (T.YourXMLColumn, '<', -1 ) ) ;

Another option is just rebuilding the content with the new value

UPDATE YourTable T SET
T.YourXMLColumn = '<VoucherID>' || 
                  T.YourValueColumn || 
                  '</VoucherID>';
Sign up to request clarification or add additional context in comments.

Comments

0

Why don't you select the value in the right colomn and then make an update ? If you've a lot of switches to do you can use a loop, offcours it can be realy slow but it's the easier way, I think...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.