06-17-2008
Hai Hema,
Spool concept is not required in the shell scripting. Simply you can create a blank .csv file using `touch` command in unix.
Spool concept is useful only in Windows. what ever you are passing the sqlfile.sql( Input to Script )those are declared in the SQL-Part (Begin - - End
of the below mentioned code (Execute simple Procedure):
RETVAL=`sqlplus -s USERNAME/PASSWORD@DBNAME <<EOF
SET SERVEROUTPUT ON SIZE 100000
Declare
OUT_STATUS NUMBER;
OUT_MSG VARCHAR2(200);
Begin
ODS_SP_REMOVE_PRE_SUB_DUP(OUT_STATUS, OUT_MSG);
dbms_output.put_line ('KeepThis '||OUT_STATUS ||' '||nvl(OUT_MSG,''));
End;
/
SET SERVEROUTPUT OFF
EXIT;
EOF`
X=`echo $RETVAL | grep KeepThis | awk '{print $2}'`
Y=`echo $RETVAL | grep KeepThis | awk '{print $3}'`
echo " " >> $USER_LOG
echo "Procedure: ODS_SP_REMOVE_PRE_SUB_DUP output is: " >> $USER_LOG.CSV
echo "OUT_STATUS= $X" >> $USER_LOG.CSV
echo "OUT_MSG= $Y " >> $USER_LOG.CSV
Note: You need to create the CSV file before call the Oracle Procedure.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I am trying to pass some of the variables in my shell scripts to the sqlplus call and use them as parameters.
For example, I would like to replace the 'SAS', and '20050612' with $var1 and $var2, respectively, how can I do that?
--------------------------------------------------------... (1 Reply)
Discussion started by: Jtrinh
1 Replies
2. Shell Programming and Scripting
if
then
# mail -s "Import failed file does not exist" sanjay.jaiswal@xyz.com
echo "FILE does not exist"
exit 1
fi
echo "FILE EXIST"
size=-1
set $(du /export/home/oracle/nas/scott21.dmp.gz)
while
do
echo "Inside the loop"
size=$1
set $(du... (1 Reply)
Discussion started by: sanora600
1 Replies
3. Shell Programming and Scripting
Hi,
I need help urgently for following issue. Pls help me to resolve this issue.
I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql)
I given... (6 Replies)
Discussion started by: praka
6 Replies
4. Shell Programming and Scripting
Hi,
I am using SYBASE database. in my script i am connecting to DB via using isql.
isql -U${S_USER} -S${S_SERV} -D${S_DB} -P${S_PWD} -b0 -w3000 -h0 -s"|" -i${MYDIR}/ABC.sql -oXYZ.txt << FINSQL
i am taking a ABC.sql file to use the queries written in it and storing the output in... (3 Replies)
Discussion started by: dazdseg
3 Replies
5. UNIX and Linux Applications
using sqlplus I want to execute a .sql script that has dbms_output statments in rhe script. I want to write the dbms_output statements from .sql file to a log file. is this possible. thanks
any help would be appreciated
:wall: (1 Reply)
Discussion started by: TRS80
1 Replies
6. Shell Programming and Scripting
Gurus,
The issue I'm having is that my Shell won't accept SQL parameters properly......
Here's they way I'm running it....
applmgr@ga006hds
=> sh CW_MigrationDeployScript.sh apps <appspwd> <SID> '01-JAN' '31-MAR'
The process just hangs not submitting the SQL job...
... (3 Replies)
Discussion started by: WhoDatWhoDer
3 Replies
7. Shell Programming and Scripting
echo "set echo off"; echo "set feedback off"; echo "set linesize 4000"; echo " set pagesize 0"; echo " set sqlprompt ''"; echo " set trimspool on";
Select statement is mentioned below
echo "select res.ti_book_no from disney_ticket_history res where res.ti_status =${STATUS} and... (7 Replies)
Discussion started by: aroragaurav.84
7 Replies
8. Programming
i have file in which i have employee id are there and every time number of employee id are different in file means number of count of employee id in file are every time different.
343535435
365765767
343534543
343543543
i want to pass this file to sqlplus
and sql command is
... (7 Replies)
Discussion started by: pallvi_mahajan
7 Replies
9. Shell Programming and Scripting
Hi All,
I am new to shell script. I am trying to pass value from .sh file to .sql file .
But I am able to run the .sql file from .sh file with values in sql file.
But I am unable to pass the values from .sh file. can some one please help to resolve this.
here is my .sh file
s1.sh
... (4 Replies)
Discussion started by: reddy298599
4 Replies
10. UNIX for Beginners Questions & Answers
hello friend good morning
I have a problem, how can I take the value that the PROCEDURE returns to me in the variable "CodError", when the connection to the bbdd is closed I lose the value and I need it in the shell
#AIX
cat <<EOF | sqlplus -s ${ORA_LOGIN}/${ORA_PASSWORD} > $logftmp
set... (6 Replies)
Discussion started by: tricampeon81
6 Replies
LEARN ABOUT SUSE
dbd::file
DBD::File(3) User Contributed Perl Documentation DBD::File(3)
NAME
DBD::File - Base class for writing DBI drivers
SYNOPSIS
This module is a base class for writing other DBDs.
It is not intended to function as a DBD itself.
If you want to access flatfiles, use DBD::AnyData, or DBD::CSV,
(both of which are subclasses of DBD::File).
DESCRIPTION
The DBD::File module is not a true DBI driver, but an abstract base class for deriving concrete DBI drivers from it. The implication is,
that these drivers work with plain files, for example CSV files or INI files. The module is based on the SQL::Statement module, a simple
SQL engine.
See DBI for details on DBI, SQL::Statement for details on SQL::Statement and DBD::CSV or DBD::IniFile for example drivers.
Metadata
The following attributes are handled by DBI itself and not by DBD::File, thus they all work like expected:
Active
ActiveKids
CachedKids
CompatMode (Not used)
InactiveDestroy
Kids
PrintError
RaiseError
Warn (Not used)
The following DBI attributes are handled by DBD::File:
AutoCommit
Always on
ChopBlanks
Works
NUM_OF_FIELDS
Valid after "$sth-"execute>
NUM_OF_PARAMS
Valid after "$sth-"prepare>
NAME
Valid after "$sth-"execute>; undef for Non-Select statements.
NULLABLE
Not really working, always returns an array ref of one's, as DBD::CSV doesn't verify input data. Valid after "$sth-"execute>; undef for
Non-Select statements.
These attributes and methods are not supported:
bind_param_inout
CursorName
LongReadLen
LongTruncOk
Additional to the DBI attributes, you can use the following dbh attribute:
f_dir
This attribute is used for setting the directory where CSV files are opened. Usually you set it in the dbh, it defaults to the current
directory ("."). However, it is overwritable in the statement handles.
f_ext
This attribute is used for setting the file extension where (CSV) files are opened. There are several possibilities.
DBI:CSV:f_dir=data;f_ext=.csv
In this case, DBD::File will open only "table.csv" if both "table.csv" and "table" exist in the datadir. The table will still be named
"table". If your datadir has files with extensions, and you do not pass this attribute, your table is named "table.csv", which is
probably not what you wanted. The extension is always case-insensitive. The table names are not.
DBI:CSV:f_dir=data;f_ext=.csv/r
In this case the extension is required, and all filenames that do not match are ignored.
f_schema
This will set the schema name. Default is the owner of the folder in which the table file resides. "undef" is allowed.
my $dbh = DBI->connect ("dbi:CSV:", "", "", {
f_schema => undef,
f_dir => "data",
f_ext => ".csv/r",
}) or die $DBI::errstr;
The effect is that when you get table names from DBI, you can force all tables into the same (or no) schema:
my @tables $dbh->tables ();
# no f_schema
"merijn".foo
"merijn".bar
# f_schema => "dbi"
"dbi".foo
"dbi".bar
# f_schema => undef
foo
bar
Driver private methods
data_sources
The "data_sources" method returns a list of subdirectories of the current directory in the form "DBI:CSV:f_dir=$dirname".
If you want to read the subdirectories of another directory, use
my ($drh) = DBI->install_driver ("CSV");
my (@list) = $drh->data_sources (f_dir => "/usr/local/csv_data" );
list_tables
This method returns a list of file names inside $dbh->{f_dir}. Example:
my ($dbh) = DBI->connect ("DBI:CSV:f_dir=/usr/local/csv_data");
my (@list) = $dbh->func ("list_tables");
Note that the list includes all files contained in the directory, even those that have non-valid table names, from the view of SQL.
KNOWN BUGS
o The module is using flock () internally. However, this function is not available on all platforms. Using flock () is disabled on
MacOS and Windows 95: There's no locking at all (perhaps not so important on MacOS and Windows 95, as there's a single user
anyways).
AUTHOR
This module is currently maintained by
H.Merijn Brand < h.m.brand at xs4all.nl > and Jens Rehsack < rehsack at googlemail.com >
The original author is Jochen Wiedmann.
COPYRIGHT AND LICENSE
Copyright (C) 2009 by H.Merijn Brand & Jens Rehsack Copyright (C) 2004 by Jeff Zucker Copyright (C) 1998 by Jochen Wiedmann
All rights reserved.
You may freely distribute and/or modify this module under the terms of either the GNU General Public License (GPL) or the Artistic License,
as specified in the Perl README file.
SEE ALSO
DBI, Text::CSV, Text::CSV_XS, SQL::Statement
perl v5.12.1 2009-06-05 DBD::File(3)