Sponsored Content
Top Forums Shell Programming and Scripting Spool file, only if data exists. Post 302545938 by cero on Wednesday 10th of August 2011 04:03:30 AM
Old 08-10-2011
@pludi: controlling SQL*Plus commands like spool with PL/SQL is hard, but SQL*Plus can be tricked to act conditional.
Code:
column spool_destination noprint new_value spooldestination
SELECT DECODE(COUNT(*),0,'/dev/null','spoolfilename')  AS spool_destination
  FROM temporary_table_containing_resultset;
spool &spooldestination
SELECT * 
  FROM temporary_table_containing_resultset;
spool off

These 2 Users Gave Thanks to cero For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to spool a unix file

hi, can anyone help me by saying how can i spool a unix file.. do we need to specify the pathname as such to spool the file .. right now, i tried giving like spool filename in the sql prompt.. but its not giving me the required output even if i can see that the command is being executed.. ... (2 Replies)
Discussion started by: kripssmart
2 Replies

2. UNIX for Dummies Questions & Answers

SQLPlus spool file

HI Have some problem with spooling out some relatively large number of records (~2-3 mil) Small table - OK though. Getting error: SP2 0308: cannot close spool file. Any thoughts? sqlplus -s user/pwd << EOF set term off set head off set trims on set pages 0 set... (1 Reply)
Discussion started by: Leo_NN
1 Replies

3. AIX

Spool data file

Dear Gurus, Tried searching for some clues in this forum but dont seem to be able to find my answer. :confused: Anyway i have a quick question: Today I have produced a messages generated from a application and placed them on the print queue. Before this I had stopped the printer queue, so... (2 Replies)
Discussion started by: lweegp
2 Replies

4. Shell Programming and Scripting

Problem in spool file

Hi, Iam a newbie. When I give the below query at SQL prompt. SQL> select col1||'`ß`'||col2 from tablename where rownum<2; 1-J7WGX`ß`1-7OKC-23 Iam getting ß within appostropies...... If I remove appostropies and give the query it is throwing an error. If I give the same query in spool as... (1 Reply)
Discussion started by: kknayak
1 Replies

5. Shell Programming and Scripting

spool to file in ksh

hi all, am trying to write a ksh script which will take a username, password, db instance as input arguments and login to the database using sqlplus and select some data via sql and spool to a file. problem is that i am using "sqlplus -s" in order to hide the username/password and it doesnt... (8 Replies)
Discussion started by: cesarNZ
8 Replies

6. Shell Programming and Scripting

File exists, but cannot be opened.How to check- whether it could be opened to read when it exists

Hi #Testing for file existence if ; then echo 'SCHOOL data is available for processing' else echo 'SCHOOL DATA IS NOT AVAILABLE FOR PROCESSING' : i wrote a script, where it begins by checking if file exists or not. If it exists, it truncates the database... (2 Replies)
Discussion started by: rxg
2 Replies

7. Shell Programming and Scripting

Spool Data in a file

Hello, I am trying to spool data from database into a file on solaris through ksh. Data is getting fetched but the problem is record is getting split in to multiple lines. excerpt from sql is whenever sqlerror exit 1; set define on set echo off set feed off set head off set... (1 Reply)
Discussion started by: abhi1988sri
1 Replies

8. UNIX for Dummies Questions & Answers

Column Header in the Spool file

Hi All, I have a problem with the column heading while spooling the data from the database. Since i want the column header, therefore i am not using SET HEADING OFF, and i am getting the header, but for the longer column name, some of the character from the column name is missing. for... (7 Replies)
Discussion started by: Pramod_009
7 Replies

9. Shell Programming and Scripting

Spool file requirement

Hi, I have a requirement of Connecting to sqlplus from unix Execute the package. The output of package is stored in a table Need to query the table and move to txt file. The problem iam facing is, when I try to spool the file. I get the sql query also along with the output.... (6 Replies)
Discussion started by: Shanmugapriya D
6 Replies

10. Shell Programming and Scripting

Order of data in Spool File

Hello, I have a shell script through which I am executing .sql file and spooling the result of Query from .sql . I want to spool the result in ascending order. Is there any parameter to be set to print result in ascending or descending order. Thanks in advance. (4 Replies)
Discussion started by: Aparna.N
4 Replies
snfetch,v0.3.8(8)					      System Manager's Manual						 snfetch,v0.3.8(8)

NAME
snfetch - fetch articles. SYNOPSIS
snfetch [-r] [-t timeout] [-c depth] group [serial [max]] DESCRIPTION
snfetch expects to read NNTP from file descriptor 6, and write NNTP to file descriptor 7, which descriptors must have already been open. Articles retrieved are written to descriptor 1. Each article displayed is separated from the next by a dot on a line by itself. These articles are NNTP safe, in the sense that double-dot unquoting is not done, and all lines end in CR-LF. snfetch expects to begin it's NNTP speech by giving the GROUP command. The upstream server's greeting must have already been read some other way. Likewise, when snfetch is done, it will not send a QUIT command. The output is suitable for feeding to snstore. snfetch always checks the article ID of the prospective article before retrieving it. If the ID already exists in the ID database, the article will not be retrieved. Note that this does not guarantee that all articles retrieved will be unique. snfetch does not guarantee to leave the NNTP conversation in a decent state (there might be more data to read, but snfetch aborted part way). You will need to be root or own /var/spool/sn in order to run this program. It is not safe to direct the output of several snfetches to the same pipe descriptor, but a file descriptor is all right. OPTIONS
-t timeout snfetch will wait only timeout seconds (default 180) for data before giving up, if the server doesn't respond. -r Output in news batch format instead. All articles will take the #! rnews form only, even if there is just one article, all lines end in bare linefeed, and dot-unquoting is performed. -c depth Employ a command pipeline of depth depth. NNTP command pipelining is not officially sanctioned, so by default no pipeline is used. However, a pipeline with a depth greater than 0 will substantally reduce transaction latency if the server accepts it. A respectable value for depth might be between 1 and 5. ARGUMENTS
snfetch takes the name of a single newsgroup on its command line. If serial is given, this is taken to be the first article number on group on the server to fetch. If max is specified, this is taken to be the maximum number of articles to fetch. The first article retrieved may be after serial if max would be violated. If max is not specified, there is no limit. ENVIRONMENT VARIABLES
SNROOT If this is set and is not empty, the value is used in place of /var/spool/sn, the default news spool directory. FILES
/var/spool/sn/newsgroup/.serial If serial is not specified, the starting serial number is taken from the file /var/spool/sn/newsgroup/.serial. This defaults to 0 if the file can't be read. /var/spool/sn/newsgroup/.serial.tmp If snfetch exits with success (0), the new serial is written into this file. The original file /var/spool/sn/newsgroup/.serial is readonly by snfetch. /var/spool/sn/newsgroup/.max If max is not specified on the command line, max is read from this file. If the file cannot be read or does not exist, there is no limit. EXIT CODES
snfetch exits 1 on usage error, 2 on system failure, 3 on protocol error, 4 on read timeout, and 0 on success. SEE ALSO
snstore (8), snget (8) N.B. Harold Tay snfetch,v0.3.8(8)
All times are GMT -4. The time now is 12:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy