06-22-2007
Shell Script - SQL
Guys,Please look at a simple shell which validates presence of a customer table in OASIS schema. SQL Query for validation is wrong(Table name in quotes should not have schema name OASIS.). And shell is working correctly (with exit 1) as it will never get count=1 with this query.
But it is failing today in our application.and it was not failing in last 6 months with the same code.(This shell is running as host - concurrent program in oracle applications ERP) . Any suggetions/thoughts.
Thanks and Regards,
Bhushan
#!/bin/sh
# Parameter Name Description
# ------------ --------------------
# $1 = Ora apps/user ID
# $2 = User id
# $3 = User Name
# $4 = Request Id
ORA_USERPASS=${1}
#----------------------------------------------#
Validate Database table exists or not
#----------------------------------------------#
TP_PASS=`sqlplus -s /nolog <<end_stmt1
set heading off
set feedback off
set verify off
set termout off
set pages 0
connect $ORA_USERPASS
select count(*)
from all_objects
where object_name = 'OASIS.CUSTOMER_STAGE_TABLE'
and owner='OASISAR'
and status='VALID';
end_stmt1`
TP_PASS=`echo $TP_PASS|cut -d" " -f2`
if ! [ $TP_PASS = 1 ]
then
echo " Staging table OASIS.CUSTOMER_STAGE_TABLE is not present in the schema OASIS" >> $OUTPUT
ERROR_FLAG="Y"
echo " " >> $OUTPUT
exit 1
fi
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have an issue. There is a file that has got some values seperated by commas. I have to write a shell script that would extrct these values and insert them into a table. How can this be done
Thanx in advance (3 Replies)
Discussion started by: sendhil
3 Replies
2. Shell Programming and Scripting
Hi,
I am able to insert the values into a database table from a flat file using SQL loader. Now can I do the same using only shell script.Can this be done without using sql loader and only with shell scripting(ie use of awk). Please put some light on this.
Thanks in advance (3 Replies)
Discussion started by: sendhil
3 Replies
3. Shell Programming and Scripting
Hi-
I am trying to achieve the following in a script so I can schedule it on a cron job. I am fairly new to the unix environment...
I have written a shell script that reads a flat file and loads the data into an Oracle table (Table1) via SQLLDR. This Works fine. Then, I run a nested insert... (5 Replies)
Discussion started by: rajagavini
5 Replies
4. 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
5. Shell Programming and Scripting
I need help in the following script. I want to grep the sql errors insert into the error table and exit the shell script if there is any error, otherwise keep running the scripts.
Here is my script
#!/bin/csh -f
source .orapass
set user = $USER
set pass = $PASS
cd /opt/data/scripts
echo... (2 Replies)
Discussion started by: allinshell99
2 Replies
6. Shell Programming and Scripting
sqlplus -s <<__END__
${USER}/${PASS}@${DB}
WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK
WHENEVER OSERROR EXIT FAILURE ROLLBACK
SET ECHO ON
SET TIMING ON
SET SERVEROUTPUT ON SIZE 1000000
select count(*) from table where start LIKE '10-JUN-10';
EXIT
__END__
result=$?
echo $resultThis gives... (9 Replies)
Discussion started by: sandy1028
9 Replies
7. Shell Programming and Scripting
There are 4 parameters that I have to pass from korn shell to sql script.
1) I have to check if $1 , $2 , $3 and $4 are null values or not .
How can I do that ?
2) Once its determined that these values are null (in the sense they are empty) how can I pass null values to sql script... (11 Replies)
Discussion started by: megha2525
11 Replies
8. Shell Programming and Scripting
Hi, this's Pom. I'm quite a new one for shell script but I have to do sql on shell script to query some information from database.
I found a concern to get a new line...When I run my script, it retrieves all data as wondering but it's shown in one line :(
What should I do? I'm not sure that... (2 Replies)
Discussion started by: Kapom
2 Replies
9. UNIX for Dummies Questions & Answers
Hi,
I need to excute two .sql scripts sequentially within file.sh
sqlplus user/pass@db1 @/opt/Infor/Outbound_Marketing/7.2.2/custom/iadeploy1.sql
THEN
sqlplus user/pass@db2 @/opt/Infor/Outbound_Marketing/7.2.2/custom/iadeploy3.sql
Thanks,
Soph (4 Replies)
Discussion started by: soph1997
4 Replies
10. Shell Programming and Scripting
Hi all,
$ echo $SHELL
/bin/bash
Requirement - How to pass oracle sql script as argument to unix shell script?
$ ./output.sh users.sql
Below are the shell scripts and the oracle sql file in the same folder.
Shell Script
$ cat output.sh
#!/bin/bash
.... (7 Replies)
Discussion started by: a1_win
7 Replies
LEARN ABOUT CENTOS
platform::shell
platform::shell(n) Tcl Bundled Packages platform::shell(n)
__________________________________________________________________________________________________________________________________________________
NAME
platform::shell - System identification support code and utilities
SYNOPSIS
package require platform::shell ?1.1.4?
platform::shell::generic shell
platform::shell::identify shell
platform::shell::platform shell
_________________________________________________________________
DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell.
This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only
requirement is that the other shell (identified by its path), is actually executable on the current machine.
While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell
this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run
32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers.
For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed
packages, versus the architecture of the shell running the repository software.
COMMANDS
platform::shell::identify shell
This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell.
platform::shell::generic shell
This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell.
platform::shell::platform shell
This command returns the contents of tcl_platform(platform) for the specified Tcl shell.
KEYWORDS
operating system, cpu architecture, platform, architecture
platform::shell 1.1.4 platform::shell(n)