![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| SUN Solaris The Solaris Operating System, usually known simply as Solaris, is a free Unix-based operating system introduced by Sun Microsystems . |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Please help on IF statements. | filthymonk | Shell Programming and Scripting | 4 | 07-18-2007 02:59 AM |
| Else in If Statements | chapmana | UNIX for Dummies Questions & Answers | 8 | 11-30-2006 04:07 AM |
| Conditional Statements | cstovall | Shell Programming and Scripting | 1 | 05-15-2005 02:58 PM |
| or statements? | Blip | Shell Programming and Scripting | 1 | 01-19-2004 12:08 PM |
| if statements | lilas | UNIX for Dummies Questions & Answers | 2 | 03-22-2001 07:49 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Automate SQL statements
Hello,
On unix side, I have written below script for taking oracle db backup. But when I tried to execute it - i could not execute the sql statements from unix. Please suggest ------------------------ $ more bkp.sh #!/bin/ksh # make sure database is shutdown cleanly sqlplus '/ as sysdba' <<eof { shutdown immediate; startup force dba pfile=$ORACLE_HOME/dbs/init.ora; shutdown immediate; } exit; eof #Mount the database and start backup run { startup mount pfile=$ORACLE_HOME/dbs/init.ora; } # Backup datafile, controlfile and archivelogs rman target=/ << EOF RUN { allocate channel ch1 type disk format '/u00/oradata/backup/%d_DB_%u_%s_%p_%t'; backup database include current controlfile tag = '1_daily_backup'; release channel ch1; } EXIT; EOF # Open the database run { alter database open; } # Archive all logfiles including current run { sql 'ALTER SYSTEM ARCHIVE LOG CURRENT'; } # Backup outdated archlogs and delete them rman target=/ << EOF RUN { allocate channel ch1 type disk format '/u00/oradata/backup/%d_DB_%u_%s_%p_%t'; backup archivelog until time 'Sysdate-2' all delete input; release channel ch1; } EXIT; EOF # Backup remaining archlogs rman target=/ << EOF RUN { allocate channel ch1 type disk format '/u00/oradata/backup/%d_DB_%u_%s_%p_%t'; backup archivelog all; release channel ch1; } EXIT; EOF ------------------------ Thank you! |
| Forum Sponsor | ||
|
|
|
|||
|
Ok - I get what was wrong in the script. I was running sql commands within run { } , i have modified and kept all sql statements within sqlplus '/ as sysdba' <<eof
{ ... } and all the rman related commands under rman target=/ << EOF RUN { ... } The script looks to be working fine now - Thanks. Except one below error in below piece: sqlplus '/ as sysdba' <<eof { shutdown immediate; startup mount; } exit; eof Error is: SQL> SP2-0042: unknown command "}" - rest of line ignored. |
|
|||
|
Thanks - The problem is resolved now and I learn that in unix script style - SQL commands dont require parenthesis and will run as below:
sqlplus '/ as sysdba' <<eof alter database open; ALTER SYSTEM ARCHIVE LOG CURRENT; exit; eof Thank you for the hints. |
|||
| Google The UNIX and Linux Forums |