2011-03-24 3 views
0

만약 내가 3 SQL 스크립트를 가지고 스풀에 출력을 덤프 & 1 첫 번째 SQL 스크립트에서 내가 스풀 & 2 번째 SQL 스크립트 출력을 덤프해야합니까 .. 나는 그 모든 출력 다른 cshell 스크립트에서 .. 어떤 하나 스풀 & 1 일을 어떻게하는지 나에게 설명 할 수오라클 SQL 스크립트 스풀 & 1

답변

1

&1은 위치 매개 변수입니다. 당신의 CSH 스크립트가 세 개의 SQL 스크립트를 호출하고 그들은 모두 스풀을 포함 할 경우 출력이 명령 줄의 첫 번째 인수로 전달할 파일 이름으로 이동 spool &1 의미 사용

, 그들은 각 &1, 두 번째 참조해야합니다 &2을 사용하지 않습니다. (파일 이름이 각각의 경우 첫 번째 인수 인 한). 그리고 'counter'는 SQL * Plus 세션마다 1로 재설정됩니다. spool &1 포함됩니다

#!/bin/csh 
sqlplus -s/@query1 output_file_1 
sqlplus -s/@query2 output_file_2 
sqlplus -s/@query3 output_file_3 

SQL 스크립트의 각, 출력은 다른로 이동합니다 : 당신이 SQL 스크립트 query1.sql, query2.sql 및 query3.sql라고 한다면, 당신의 CSH 스크립트 같은 것을 보일 수 있습니다 파일. 그런 다음 동일한 csh 스크립트의 다른 위치에서 출력 파일을 참조 할 수 있습니다.

로버트 그가 같은 파일에 가서 모든 출력을 원한다면, 당신은 세 가지 sqlplus 명령에 동일한 파일 이름을 전달하고 두 번째와 세 번째 스풀 명령이해야 할 것, 인용 문서에 언급 된 바와 같이 APP[END] 인수

+0

감사합니다. 많은 도움이됩니다. – jack

1

Asuming 당신은 버전 10g이 이상 당신이 다음 옵션을

SQL> spool name_of_file 
SQL> spool name_of_file off 
SQL> spool name_of_file out 
SQL> spool name_of_file create 
SQL> spool name_of_file append 
SQL> spool name_of_file replace 

온라인 미세 신탁의 힘을 과소 평가하지 말라 문서 :

CRE[ATE] 
Creates a new file with the name specified. 
REP[LACE] 
Replaces the contents of an existing file. If the file does not exist, REPLACE creates the 
file. This is the default behavior. 
APP[END] 
Adds the contents of the buffer to the end of the file you specify. 
OFF 
Stops spooling. 
OUT 
Stops spooling and sends the file to your computer's standard (default) printer. This 
option is not available on some operating systems. 
Enter SPOOL with no clauses to list the current spooling status