SQL命令在交互模式下有效,但在Oracle数据库中的bash脚本中无效

时间:2018-07-04 17:58:18

标签: sql linux bash oracle sqlplus

在sqlplus中可用的命令

INSERT INTO DATA_SM_METRIC(UNIQUE_ID,METRIC_REVIEW_CRITERION_DESC,METRICS_REVIEW_CRITERION_VALUE,ENTITY_TYPE,REVIEWCRITERIATYPE,CREATETIME)
SELECT UNIQUE_ID,METRIC_REVIEW_CRITERION_DESC,METRICS_REVIEW_CRITERION_VALUE,ENTITY_TYPE,REVIEWCRITERIATYPE,CREATETIME FROM DATA_SM_METRIC_STG; 

当插入到shell脚本中时,它只是暂停,并且从未执行过。 ... stg表被填充,所有记录都被转移到另一个表中。为什么未将其从登台表填充到另一个表中?

脚本:

DATAFILE=$1

SQLPATH=/u01/app/oracle/product/12.2/db_1/bin

SQLPLUS=$SQLPATH/sqlplus

SQLLOADER=$SQLPATH/sqlldr


echo "Start loading file into staging table ->sqlldr $DATAFILE"

$SQLLOADER userid=system/oracle@127.0.0.1:1521/orcl12c 
control=./$DATAFILE.ctl data=./$DATAFILE log=./$DATAFILE.log  
bad=./$DATAFILE.bad skip=1 errors=100
echo $?


echo "start inserting records......"
rec=`$SQLPLUS -S  system/oracle@127.0.0.1:1521/orcl12c  <<EOF | sed 1,3d        
INSERT INTO CIBC_DATA_SM_METRIC(UNIQUE_ID,METRIC_REVIEW_CRITERION_DESC,METRICS_REVIEW_CRITERION_VALUE,ENTITY_TYPE,REVIEWCRITERIATYPE,CREATETIME)
SELECT UNIQUE_ID,METRIC_REVIEW_CRITERION_DESC,METRICS_REVIEW_CRITERION_VALUE,ENTITY_TYPE,REVIEWCRITERIATYPE,CREATETIME FROM CIBC_DATA_SM_METRIC_STG; 
exit
EOF`

0 个答案:

没有答案