Capture a database val and use in script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Capture a database val and use in script
# 1  
Old 09-16-2013
Capture a database val and use in script

Hello, sorry if this has been asked before, I couldn't find what I was looking for.

I know how to connect to Oracle and execute stored procedures from a shell script, but what I would like to do is return a value from a table and use it in my script.

For Example, If I had a table Called TableX that had a value called ProcessToday and it was set to 'Y', I would like to read that value and set a variable in my shell script so I could do something like

TheValue= (returned value from query)

Code:
if [ $TheValue = 'Y']
   .....

Anyone know if this is possible and how I would set this up? Thanks in advance.
# 2  
Old 09-16-2013
Save the returned output to a variable or file and parse it in your shell script.

Basic example:
Code:
... maybe put some sqlplus settings here to get not too much garbage etc...
... and set the environment needed for your DB user, if not already done...
VAR=$( sqlplus user/pw @ ... )

If you get more output, parsing will be needed.

Here is one of many hits on Google how to issue sqlplus from a shell script which is demonstrated more in detail:
https://forums.oracle.com/thread/2174382
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

2. Shell Programming and Scripting

How to capture the exit code of a shell script in a perl script.?

hi, i want to pop up an alert box using perl script. my requirement is. i am using a html page which calls a perl script. this perl script calls a shell script.. after the shell script ends its execution, i am using exit 0 to terminate the shell script successfully and exit 1 to terminate the... (3 Replies)
Discussion started by: Little
3 Replies

3. Shell Programming and Scripting

How to capture exit code of child script and send it to parent script?

#!/usr/local/bin/bash set -vx /prod/HotelierLinks/palaceLink/bin/PalacefilesWait /prod/HotelierLinks/palaceLink/bin/prodEnvSetup 03212013 & if then echo "fatal error: Palace/HardRock failed!!!!" 1>&2 echo "Palace Failed" | mail -s "Link Failed at Palace/HardRock" -c... (1 Reply)
Discussion started by: aroragaurav.84
1 Replies

4. Shell Programming and Scripting

database instance Error capture

I wrote a script to capture some rows from the DB. However I want to capture the errors if the DB instance is down which usually produces errors like below. What should be my approach to kill script if the DB instance is down: DATABASE ERRORS: Msg 937, Level 14, State 1: Server... (2 Replies)
Discussion started by: moe458
2 Replies

5. UNIX for Advanced & Expert Users

How to capture STDOut of script in a CGI script?

Hi Perl Experts, I am invoking a shell script thru a perl script and the perl script is cgi script.I need to capture the STDOUT of the shell script in the html page where I am invoking the script .?The shell script takes couple of mintutes to complete its execution .Mean while my html page does... (1 Reply)
Discussion started by: kittu1979
1 Replies

6. Shell Programming and Scripting

script to capture

Hi In my production server some user runnig some scripts to get some data. I need a script to capture this user script code. best rds ab (5 Replies)
Discussion started by: aboorkuma
5 Replies

7. UNIX for Dummies Questions & Answers

Howto capture data from rs232port andpull data into oracle database-9i automatically

Hi, i willbe very much grateful to u if u help me out.. if i simply connect pbx machine to printer by serial port RS232 then we find this view: But i want to capture this data into database automatically when the pbx is running.The table in database will contain similar to this view inthe... (1 Reply)
Discussion started by: boss
1 Replies

8. Shell Programming and Scripting

vmstat returns good val for cpuIdle put ps shows no active process

hi i'm running a shell script that checks the amount of cpu idle either using /usr/bin/vmstat 1 2 or sar 1 2 (on unixware) before i run some tests(if cpu idle greater than 89 I run them). These tests are run on many platforms, linux(suse, redhat) hp-ux, unixware, aix, solaris, tru64. ... (5 Replies)
Discussion started by: OFFSIHR
5 Replies

9. Programming

Capturing a ret val of C obj file in ksh script

Hi, I have one shell script which is calling a C executable. That C executable returns a value depending upon operations inside the C code. But how to get that value in the calling shell script? The syntax of calling the C executable is like -- C_exec <argc no> <argument1> <argument2> etc... (5 Replies)
Discussion started by: k_bijitesh
5 Replies

10. Shell Programming and Scripting

ret val of a command in a pipe which is NOT the last one

hello dear UNIX gurus ;-) my problem is one of those i would think that many others should also have had it in the past. but i cannot find any thread or other documentation about it. inside a ksh script i have a pipe like this: ksh -c "export LIBPATH=$LD_LIBRARY_PATH; ${Cmd} ${Param} 2>&1... (5 Replies)
Discussion started by: latze
5 Replies
Login or Register to Ask a Question