作者:lock2502898047_947 | 来源:互联网 | 2023-05-18 05:01
#!/bin/bash
sqlplus system/report@orcl <
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF
col nur new_value n_nur
select sum(balance) nur from T_DJF_SHELL;
exit n_nur;
EOF
value="$?"
echo "File:$value"
这是一个简单的脚本,想实现用变量接受sql的执行结果。
执行后:
SQL*Plus: Release 11.2.0.3.0 Production on Wed Oct 28 15:41:24 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> SQL> SQL> 8042000
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
File:16
想请问下我上面的sql语句的sum值是8042000,但是$value的值是16这是为什么啊?,我想接受到8042000该怎么做?
4 个解决方案
$?的范围是0~255,也就是,如果上一条命令返回值是8042000,那么最终结果就是8042000&255=16