Config SQL*Plus to return nothing but data

前端 未结 2 2099
情话喂你
情话喂你 2021-01-06 09:32

I need to write a simple shell function that returns a single field from an Oracle DB. Think of it as for example SELECT \'ABC\' FROM dual; and ABC is what I a

2条回答
  •  温柔的废话
    2021-01-06 10:34

    Based on Justin's answer (which is great), when you only need to select one number (or token), I consider this a little shorter, yet more readable version:

    x=`sqlplus -S / <<< "select 'KEEP' , max(sal) from emp;" | awk '/KEEP/{print $2}'`
    

提交回复
热议问题