Oracle 'printf' equivalent

前端 未结 5 1510
时光说笑
时光说笑 2021-01-04 07:31

Is there an equivalent or alternative to the following?

SELECT mix_type || \' (\' || mix_num || \')\' as description
  FROM acid_batch
 WHERE mix_num < 10         


        
5条回答
  •  花落未央
    2021-01-04 08:06

    The closest standard approximation to printf for Oracle I can think of is utl_lms.format_message. However, it won't work in SQL statements, that is, this is ok:

    begin
      dbms_output.put_line(
        utl_lms.format_message('hello %s, the number is %d', 'world', 42)
      );
    end;
    /
    

    but this gives a ORA-00902: invalid datatype error:

    select utl_lms.format_message('hello %s, the number is %d', 'world', 42)
      from dual
    

提交回复
热议问题