Yes, this is possible, most likely in one SQL statement. To preserve the "filename.ext" portion of the data in col2 and col3 you need to use a combination of operators:
instr, substr and the concatenation operator (||).
I'm assuming that the data in col2 and col3 varies in length from record to record. If it is all the same it is easier, just count the characters and hard-code the first argument for "substr".
You need "instr" to find the position of the last "/" character in data. By default, "instr" starts at the beginning of a string and counts forward, but if you supply a negative argument for "instr", it starts at the end of the string, so this will find the last position of "/":
instr(col2,'/',-1)
You need to use "substr" to get the filename and ext starting one position after the position that "instr" found, so your update statement for clo2 will look something like this:
update [table_name]
set col2 = [new server] || substr(col2,instr(col2,'/'
You don't need to specify the third parameter for "substr", it will default to the length it finds to the right of its start position that you found with "instr".
You can also combine the updates for col1 and col3 into one SQL statement that will do all of the updates at one time (assuming that you want all rows treated the same way).
Main Topics
Browse All Topics





by: ser6398Posted on 2002-10-28 at 09:47:05ID: 7379447
I don't understand exactly what your question is, but my best guess is that you want something like:
col2, col3
update table1
set col1 = 'DEF',
col2 = 'http://servername/dir/'||
col3 = 'http://servername/dir/'||
where col1 = 'ABC';