Oracle'printf'等价物 [英] Oracle 'printf' equivalent

查看:137
本文介绍了Oracle'printf'等价物的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有以下的等价物或替代物?

  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'等价物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆