archiveMode.sh

작동은 되나  마음에 안드는 코드임.

 

pl/sql문으로 작성해서 실행시 immediate 부분 에러남.

PLS-00103: Encountered the symbol "IMMEDIATE" when expecting one of the following:
:= . ( @ % ;

 

 

if [ $1 = start ] ; then
    sqlplus / as sysdba<<EOF
/*
    declare
        md v\$database.log_mode%type := null;
    begin
    select log_mode into md from v\$database;
        if md = 'NOARCHIVELOG' then
*/
            shutdown immediate
            startup mount
            alter database archivelog;
            alter database open;
/*
        else
            dbms_output.put_line('This Database is Archive mode');
        end if;
    end;
/
*/
    select log_mode from v\$database;
EOF
elif [ $1 = stop ] ; then
    sqlplus / as sysdba<<EOF
/*
 declare
        md v\$database.log_mode%type := null;
    begin
        select log_mode into md from v\$database;
        if md = 'ARCHIVELOG' then
*/
            shutdown immediate
            startup mount
            alter database noarchivelog;
            alter database open;
/*
        else
            dbms_output.put_line('This Database is NoArchive mode');
        end if;
    end;
/
*/
    select log_mode from v\$database;
EOF
else
    echo "Usage: archiveMode {start|stop}"

fi

+ Recent posts