473,503 Members | 7,578 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sql output in UNIX shell

55 New Member
Hi,

I wrote a shell script where I connect to an oracle db(the connection works because I able to see the DBMS output) and I execute a procedure, but I am not able to get the return value from that procedure into one of the shell variables (i understand that procedure do not return values but i am using IN OUT and i want this out value to go into a variable declared in the shell). I made sure the procedure works in sqlplus and the OUT value is comming out. Below is the code.

LOGIN=user1
DB_PWD=`some passwork`

sqlplus -s <<!
${LOGIN}/${DB_PWD}
set head off;
set feed off;
set pages 0;
set verify off;
set feedback off;
set serveroutput on;

declare
ERRFLAG number := 0;
begin
procedure_return_error(ERRFLAG);
dbms_output.put_line(ERRFLAG); /* the value gets displayed here which means the sql connection works and the OUT value is comming through */
end ;
/
!
echo errorflag is ${ERRFLAG} /* the value does not come here and dont mind the ${ERRFLAG} it does not work with just $ERRFLAG either */
echo ${APPS_LOGIN}
exit 0

I also tried declaring a global variable like below:

LOGIN=user1
DB_PWD=`some passwork`
ERRFLAG = 0 // like this but this does not work either

sqlplus -s <<!
${LOGIN}/${DB_PWD}
set head off;
set feed off;
set pages 0;
set verify off;
set feedback off;
set serveroutput on;

begin
procedure_return_error(ERRFLAG);
dbms_output.put_line(ERRFLAG); // the value gets displayed here
end ;
/
!
echo errorflag is ${ERRFLAG} // the value does not come here
echo ${APPS_LOGIN}
exit 0

Please reply,
thank you.
Sep 20 '07 #1
3 10661
radoulov
34 New Member
Expand|Select|Wrap|Line Numbers
  1. ERRFLAG="$(sqlplus -s <<!
  2. "$LOGIN"/"$DB_PWD"
  3. set pages 0 feed off serveroutput on
  4. begin
  5. procedure_return_error(ERRFLAG);
  6. dbms_output.put_line(ERRFLAG); // here you get the value
  7. end ;
  8. /
  9. !
  10. )"
  11.  
  12. echo "$ERRFLAG"
Sep 21 '07 #2
eeriehunk
55 New Member
Thank you for your reply.
As I said earlier, I am using a procedure and not a function. So technically there is no return value that comes out of the sql block to go into the UNIX variable. The value falls into the parameter of the procedure. (ie. EPALS_GL_NREG_OUT_INT(PARAM); the value falls into the parameter PARAM). so i am looking for a way to assign the value of PARAM to a UNIX variable outside the sql block.
Sep 21 '07 #3
radoulov
34 New Member
Thank you for your reply.
As I said earlier, I am using a procedure and not a function. So technically there is no return value that comes out of the sql block to go into the UNIX variable. The value falls into the parameter of the procedure. (ie. EPALS_GL_NREG_OUT_INT(PARAM); the value falls into the parameter PARAM). so i am looking for a way to assign the value of PARAM to a UNIX variable outside the sql block.

Yes,
I and as I said, you have to print it(modify your PL/SQL code or write a wrapper that prints it).
AFAIK there is no other way to pass it to the shell ....
Sep 22 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
4053
by: rkoida | last post by:
Hello evryone I am a newbie to python. I have a makefile which i can compile in UNIX/LINUX, But i I am planning to write a python script which actually does what my MAKEFILE does. The make file...
2
5653
by: Mohsin | last post by:
Hi all, I have a perl program which makes a user exit to the O/S (unix, solaris) to issue a O/S command. I know that the shell it invokes is NOT a korn shell, because I captured the shell info...
1
2025
by: dk | last post by:
is there any way to invoke a unix shell script from .net? tia, dk
0
3029
by: Aashif | last post by:
I want to call Unix Shell script which is available in other Server (Unix server) from windows application using C#. Currently the shell script runs the C program but the GUI is not good, So I want...
9
78177
by: sohan | last post by:
Hi, I want to know how to connect and execute a db2 query from inside a UNIX shell script. Details: We have a unix shell script. We need to execute multiple db2 sql queries from this shell...
3
1771
by: Deniz Dogan | last post by:
Hello. I was thinking about writing a UNIX shell program using Python. Has anyone got any experience on this? Is it even possible? I have programmed a simple shell in C before and I came to...
0
2090
by: Purple Haze | last post by:
I have a stored procedure which returns a resultset. I am calling that stored procedure from UNIX shell script. I want the data in the result set to be exported to a .csv file. How can I do this...
21
2987
by: Tom Gur | last post by:
Hi, It's seems that csh and tcsh acts a bit different when handling special characters in quotes. i.e: if i'll supply my program with the following arguments: -winpath "c:\\temp\\" tcsh will...
2
10274
by: gagandutta01 | last post by:
Hi, Can anyone tell me how to execute a function declared in Oracle Package from Unix shell script? I created a shell script and after connecting to oracle database i am using exec @...
3
4416
by: regnumber | last post by:
Hi. I am new to Unix. I need to write a Unix Shell Script to extract records from the table and write those extracted datas to a text file. DB using is DB2. Can anyone give me some sample...
0
7194
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.