Concat function is not working - invalid number of arguments

前端 未结 4 1903
粉色の甜心
粉色の甜心 2020-12-10 16:49

I have a table with two columns(Name, Occupation). I want to output the value in a format something like this.

Jane(A) 
Jenny(D) 
Julia(A)

4条回答
  •  情书的邮戳
    2020-12-10 17:04

    This happens to be one reason why I prefer replace() over concat():

    SELECT REPLACE(REPLACE('{Name} ({Occ})', '{Name}', Name'
                          ), '{Occ}', SUBSTR(Occupation, 1, 1)
                  )
    

    You can readily see the format of the string being created and easily change it. Also, REPLACE() converts arguments to the appropriate type (which Oracle does with string concatenation anyway).

提交回复
热议问题