Oracle 'printf' equivalent

formatting, oracle, printf, string

Solution

No there are no built-in Oracle functions that apply a formatting string in this fashion. Although it would be easy to write a custom function for this specific example, writing a PL/SQL-based implementation of printf would be challenging.

If you have a frequent need for this, perhaps you could write an Oracle function that wraps a Java call for a richer string handling environment.

Problem

Is there an equivalent or alternative to the following? ``` SELECT mix_type || ' (' || mix_num || ')' as description FROM acid_batch WHERE mix_num < 10 ``` Does Oracle have something like printf style formatting? ``` SELECT printf("%s (%s)", mix_type, mix_num) as description, FROM acid_batch WHERE mix_num < 10 ```

Original source