Chinaunix

标题: 小数问题 [打印本页]

作者: Ladore    时间: 2015-08-13 10:29
标题: 小数问题
  1. #!/bin/sh

  2. V_DB_USER="abcd"
  3. V_DB_PWD="abcd"
  4. V_DB_SID="orcl"

  5. t=`sqlplus -silent $V_DB_USER/$V_DB_PWD@$V_DB_SID  <<!
  6.       set pagesize 0 feedback off verify off heading off echo off
  7.             select bal from acct t where t.id='11111';
  8.             quit;
  9.             !`
  10.      echo $t > abc      

  11.      echo $t
复制代码
其中acct表中bal的值为小数,为什么输出到文件就成了整数了?
作者: tuyajie    时间: 2015-08-13 11:31
qlplus -silent $V_DB_USER/$V_DB_PWD@$V_DB_SID  <<!
      set pagesize 0 feedback off verify off heading off echo off
            select bal from acct t where t.id='11111';
            quit;
            !
这个跑出来的结果你先直接看一下呢。
作者: Ladore    时间: 2015-08-13 14:03
回复 2# tuyajie


可以这样来
  1. select bal||''||null from acct t where t.id='11111';
复制代码

作者: tuyajie    时间: 2015-08-13 15:43
所以跟shell无关了。呵呵回复 3# Ladore


   




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2