Unix Script - DB Return


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unix Script - DB Return
# 1  
Old 06-23-2011
Unix Script - DB Return

Based on the earlier thread , I made the change for the oracle sequence next val from .sh script ,
Code:
X=$(sqlplus -s user/pswd << eod
set heading off
select etl.batch_sq.nextval from dual;
eod)

when I echo to check the value
Code:
echo Batch_Id_$X

I get the following result :
Batch_Id_ 69 with a space

can someone please let me know what wrong with my step ,
when I try to hard code (override the X value), the value looks file
Code:
 
X=$(sqlplus -s user/pswd << eod
set heading off
select etl.batch_sq.nextval from dual;
eod)
X=23;

Result :
Code:
Batch_Id_23

Thanks In Advance

-

Last edited by Scott; 06-23-2011 at 03:13 AM.. Reason: Please use code tags
# 2  
Old 06-23-2011
may be your sqlplus command gives the output with space

you can use sed or tr to remove the space
# 3  
Old 06-23-2011
It's a newline, actually (if you quote the echo, you will see it).

Code:
X=$(sqlplus -s user/pswd << eod
set heading off newpage none
select trim(etl.batch_sq.nextval) from dual;
eod)

# 4  
Old 06-23-2011
Wow , it was a simple Trim , it works fine now.
Thanks guys

-
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Return: can only `return' from a function or sourced script

Not sure where the problem is. I can run the script without any issue using the following command. . /opt/app/scripts/cdc_migration.sh But it fails with the below error when I try it this way /opt/app/scripts/cdc_migration.sh /opt/app/scripts/cdc_migration.sh: line 65: return: can only... (1 Reply)
Discussion started by: svajhala
1 Replies

2. Shell Programming and Scripting

How to exit a shell script if a unix command does not return any value for 10 seconds?

Hi, Can anyone help me how to exit a shell script if a unix command inside does not return any value for 10 seconds? The scenarios is like this. I want to login to a application using shell script where the connection string is mentioned.but suppose this connection string is not... (10 Replies)
Discussion started by: arijitsaha
10 Replies

3. Shell Programming and Scripting

Need to get return code from mutt if an address is invalid/undeliverable from Unix shell script

I am using mutt on ksh Unix to send emails to addresses plucked from the database. If the "To:" email address is not longer valid and so the email is not sent to the "To:" recipient, but is sent to the valid cc address, I need to be able to get an error code returned to the shell script so that... (3 Replies)
Discussion started by: jzuber
3 Replies

4. Shell Programming and Scripting

Unix return code example

Hi, Does anyone here can guide me to understand how is return code works in a parent-child relation with a simple example? I have a request to build the script with return code in a child script, but i want to understand how does child script can return a code to the parent, stated if its... (4 Replies)
Discussion started by: khchong
4 Replies

5. Shell Programming and Scripting

Writing a UNIX script from LOG to provide return code.

Folks - Firstly, I do apologize that my first post here is a question. I am quite familiar with UNIX since our application is running on it. We are trying to automate a few things on our end and I am challenged with a task in hand that requires UNIX scripting. I am totally a newbie in UNIX... (4 Replies)
Discussion started by: sk72
4 Replies

6. Shell Programming and Scripting

how to store the return values of stored procedure in unix shell script.

hi i am calling a oracle stored procedure(in the database) from unix shell scripting (a.sh). the called stored procedure returns some values through OUT variables i want to assign the return values of stored procedure in to unix shell script variable. can you provide me the code. ... (1 Reply)
Discussion started by: barani75
1 Replies

7. HP-UX

return code from oracle to unix script

Hi I'm writing a shell script that connects to oracle database and fires query to check the availability of data in a table. In case of no data found then what will be the return code and how to handle in that in variable. Kindly provide with an example for better understanding... Thanks... (1 Reply)
Discussion started by: ksailesh
1 Replies

8. Shell Programming and Scripting

Return value from UNIX to JAVA

Hi all, is there any way to return value from UNIX to JAVA application. I have my source code like this: application.java Runtime runtime = Runtime.getRuntime(); Process p = runtime.exec(myscript); myscript.sh text="Hello World" echo $text How to return the "Hello World"... (3 Replies)
Discussion started by: suigion
3 Replies

9. UNIX for Dummies Questions & Answers

Return value from oracle to unix shell

Hi , i have written a shell scipt to call a procedure and get the value back from procedure.But i am facing the issue like #!/bin/sh returnedvalue=`sqlplus -s userid/pass<<EOF set serveroutput on; exec pass($1) set serveroutput off; EXIT; EOF` flag=`echo $returnedvalue ` echo "$flag"... (2 Replies)
Discussion started by: ravi214u
2 Replies

10. UNIX for Dummies Questions & Answers

unix return codes

Suppose I have a script which is monitoring a directory whenever a file drops in that directory,it sends alert say I want to write a return code for the above script which on successful execution of script gives a return value Based on return code , I want to do initiate some jobs in other... (1 Reply)
Discussion started by: abhib45
1 Replies
Login or Register to Ask a Question