컴퓨터활용/유닉스

shell 에서 SQL을 수행하는 예제

멜번초이 2008. 10. 11. 23:52
반응형
#!/usr/bin/sh
TEAMDIR="csv"
WORKDIR="cst"
TMAXDIR="/tmax/tmax1"

echo  "                 "
echo  "     Module Servide DBIO이관     "
echo  "                 "
sleep 1

export ENVHOME=/nbsrep/pbk/pfm/tpl/env
. $ENVHOME/profile.mod
cd  /nbsmod/$TEAMDIR/$WORKDIR/lib
A=`ls -al /nbsdev/$TEAMDIR/$WORKDIR/lib/libm$1*.so  /nbsdev/$TEAMDIR/$WORKDIR/lib/libpdb_$1*.so /nbsdev/$TEAMDIR/$WORKDIR/lib/libs$1*.so| awk '{print $9}' |cut -c 21-60`
for BL in `echo $A`
do
                cp /nbsdev/$TEAMDIR/$WORKDIR/lib/$BL /nbsmod/$TEAMDIR/$WORKDIR/lib/$BL
                chmod 777   /nbsmod/$TEAMDIR/$WORKDIR/lib/$BL
                ll          /nbsmod/$TEAMDIR/$WORKDIR/lib/$BL
                pfmdlupdate $BL
done

cd -
. $ENVHOME/profile

echo  "             "
echo  "     DBIO MAP 이관   "
echo  "             "
sleep 2

sqlplus -s apcon/apcon@TMODDB <<!
        set feedback off
        set serveroutput on
        declare
        begin
            delete from dbio_map        where map_id like '$WORKDIR_%';
            delete from dbio_map_struct where map_id like '$WORKDIR_%';
            delete from dbio_map_sql    where map_id like '$WORKDIR_%';

            insert into dbio_map select * from apcon.dbio_map@DCOREDB               where map_id like '$WORKDIR_%';
            DBMS_OUTPUT.PUT_LINE('DBIO_MAP        $IN_MAP_ID ('||sql%rowcount||')   Data  Transfer...');
            insert into dbio_map_struct select * from apcon.dbio_map_struct@DCOREDB where map_id like '$WORKDIR_%';
            DBMS_OUTPUT.PUT_LINE('DBIO_MAP_STRUCT $IN_MAP_ID ('||sql%rowcount||')   Data  Transfer...');
            insert into dbio_map_sql select * from apcon.dbio_map_sql@DCOREDB       where map_id like '$WORKDIR_%';
            DBMS_OUTPUT.PUT_LINE('DBIO_MAP_SQL    $IN_MAP_ID ('||sql%rowcount||')   Data  Transfer...');
            commit;
            DBMS_OUTPUT.PUT_LINE('DBIO DATA       $IN_MAP_ID TRANSFER SUCCESS!');
            DBMS_OUTPUT.PUT_LINE(CHR(9));
        exception
            when others then
                DBMS_OUTPUT.PUT_LINE('ERR MESSAGE :'||SQLERRM);
                rollback;
        end;
        /
!
반응형