views:

4223

answers:

3

I have a string coming from a table like "can no pay{1},as your payment{2}due on {3}". I want to replace {1} with some value , {2} with some value and {3} with some value .

Is it Possible to replace all 3 in one replace function ? or is there any way I can directly write query and get replaced value ? I want to replace these strings in Oracle stored procedure the original string is coming from one of my table I am just doing select on that table

and then I want to replace {1},{2},{3} values from that string to the other value that I have from another table

+4  A: 

Although it is not in one 'replace' call, you can nest the replace calls
SET mycol = replace( replace(mycol, '{1}', 'myoneval'), '{2}', mytwoval)

hamishmcn
A: 

If you are doing this inside of a select, you can just piece it together, if your replacement values are columns, using string concatenation.

Mitchel Sellers
+1  A: 

Are you looking for a SQL equivalent to

MessageFormat.format("can no pay {1}, as your payment {2} due on {3}", "2500", "principal", "2008-09-17");
Hank Gay
yes I am looking for the SQL equivalant to theMessageFormat.format("can no pay {1}, as your payment {2} due on {3}", "2500", "principal", "2008-09-17");
RBS