问题描述
是否有以下的等价物或替代物?
SELECT mix_type || '('|| mix_num ||')'as description
FROM acid_batch
WHERE mix_num< 10
Oracle有类似于printf风格的格式吗? b pre $ lt; code> SELECT printf(%s(%s),mix_type,mix_num) 10
没有内置的Oracle函数以这种方式应用格式化字符串。尽管为这个特定的例子写一个自定义函数是很容易的,但是编写一个基于PL / SQL的printf实现将是一个挑战。
如果您经常需要这样做,也许您可以编写一个Oracle函数来封装Java调用,以实现更丰富的字符串处理环境。 b
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
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.
这篇关于Oracle'printf'等价物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!