写一个shell脚本执行insert into tt(id,name) select id,name from yy语句
test.sh#!/bin/bash
sqlplus -s 'cisf/cisf23@cisfkfdb'<<EOF
set feed off
set heading off;
set feedback off;
set verify off;
insert into tt(id,name) select id,name from yy;
EOF没写过shell脚本,大家帮我看看!

解决方案 »

  1.   

    没什么大问题,就是在 EOF 之前,加一个 commit; 
      

  2.   

    test.sh#!/bin/bash
    sqlplus -s 'cisf/cisf23@cisfkfdb'<<EOF
    set feed off
    set heading off;
    set feedback off;
    set verify off;
    insert into T_LX_TRANS_DATE_AFIER_CLOSED(tx5_sequence.nextval,MARKET_CD,SEC_CODE, OPENED_PRICE, HIGHEST_PRICE,LOWEST_PRICE,CLOSED_PRICE,MATCH_QTY,MATCH_QMT) select MARKET,SEC_CODE,OPEN_PRICE,HIGH_PRICE,LOW_PRICE,CLOSE_PRICE,MATCH_QTY,MATCH_AMT from T_SEC_MKT_DATA;
    commit;
    exit;
    EOF部署到服务器上 执行时报错了:
    xmkf_B54_/home/cisf/cisfkf/lx $
    xmkf_B54_/home/cisf/cisfkf/lx $./test.sh
    sh: ./test.sh: Execute permission denied.
    这是什么意思?
      

  3.   

    chmod +x test.sh
    你没有给 test.sh 可执行权限或者 sh test.sh
      

  4.   

    恩 赋权限了xmkf_B54_/home/cisf/cisfkf/lx $./test.sh
    interpreter "/bin/bash" not found
    file link resolves to "/usr/bin/bash"
    sh: ./test.sh:  not found.
    xmkf_B54_/home/cisf/cisfkf/lx $ls 
    conf                 conf.properties.bak  lib                  run.sh               test.sh
    conf.properties      jms.txt              nohup.out            startJMS.sh
    xmkf_B54_/home/cisf/cisfkf/lx $
    xmkf_B54_/home/cisf/cisfkf/lx $
    文件没找到?
    怎么解决?第一次用脚本 不会啊
      

  5.   

    /bin/ls -l /proc/$$/exe 
    看一下你当前用户是 csh 还是 bash
      

  6.   

    恩 这个已经解决好了,但遇到一个很奇怪的问题:
    xmkf_B54_/home/cisf/cisfkf/lx $./test.sh
    insert into T_LX_TRANS_DATE_AFIER_CLOSED(tx5_sequence.nextval,MARKET_CD,SEC_CODE, OPENED_PRICE, HIGHEST_PRICE,LOWEST_PRICE,CLOSED_PRICE,MATCH_QTY,MATCH_QMT) select MARKET,SEC_CODE,OPEN_PRICE,HIGH_PRICE,LOW_PRICE,CLOSE_PRICE,MATCH_QTY,MATCH_AMT from T_SEC_MKT_DATA
                *
    ERROR at line 1:
    ORA-00942: table or view does not exist
    表一定存在,这是怎么回事,是不是没权限操作T_SEC_MKT_DATA这个表?
      

  7.   

    请楼主检查
    用户名和密码cisf/cisf23登陆数据库后,是否可以查询下面两张表:
     T_LX_TRANS_DATE_AFIER_CLOSED
     T_SEC_MKT_DATA1、很有可能这两张表不是在cisf用户下面。
      

  8.   

    select owner, table_name from dba_all_tables 
     where table_name = 'T_LX_TRANS_DATE_AFIER_CLOSED'
        or table_name = 'T_SEC_MKT_DATA';看下这两张表的 owner 是谁
    然后用表所属用户登陆数据库grant insert on T_LX_TRANS_DATE_AFIER_CLOSED to cisf;
    grant select on T_SEC_MKT_DATA to cisf;