- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Returning result of an Oracle stored procedure...
Operating System - HP-UX
1748038
Members
4940
Online
108757
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2002 01:41 AM
08-02-2002 01:41 AM
Solution
To pass an output parameter from a stored proc directly to a shell script variable, you can use the following technique.
#!/bin/sh
SHELL_VAR=`sqlplus -s un/pw < set feedback off pages 0
var plusvar varchar2(100)
exec stored_proc_name (:plusvar)
print plusvar
EOF`
echo ${SHELL_VAR}
# or process SHELL_VAR according to your needs
This way, you won't have to rework your stored proc to include dbms_output statements, you can use it just as it is. Also, you can return character values - SQL*Plus exit restricts you to numeric values only.
#!/bin/sh
SHELL_VAR=`sqlplus -s un/pw <
var plusvar varchar2(100)
exec stored_proc_name (:plusvar)
print plusvar
EOF`
echo ${SHELL_VAR}
# or process SHELL_VAR according to your needs
This way, you won't have to rework your stored proc to include dbms_output statements, you can use it just as it is. Also, you can return character values - SQL*Plus exit restricts you to numeric values only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2002 07:50 AM
08-02-2002 07:50 AM
Re: Returning result of an Oracle stored procedure to a shell script
Thanks Everyone - I got what I needed.
Simon - yours did work, and got me part way there. It would have been an okay workaround if I needed to.
Mark - yours also would have worked if I could not get exactly what I wanted (returning different text statuses).
Dave - Exactly what I needed.
For future reference, here is what I ended up with:
the shell script:
VALUE=`$ORACLE_HOME/bin/sqlplus -s user/pass @sqlscript`
if [ "$VALUE" = 'ERROR TYPE 1' ];
then
code to process here;
else
code to process here;
fi
the sql script:
set pagesize 0
set feedback off
set verify off
set heading off
set echo off
var out_status varchar2(30)
exec sp_tester(:out_status);
print out_status
exit;
the stored procedure:
procedure sp_tester (out_status out varchar2) is
begin
select 'ERROR TYPE 1' from dual;
end;
Thanks again everyone.
Simon - yours did work, and got me part way there. It would have been an okay workaround if I needed to.
Mark - yours also would have worked if I could not get exactly what I wanted (returning different text statuses).
Dave - Exactly what I needed.
For future reference, here is what I ended up with:
the shell script:
VALUE=`$ORACLE_HOME/bin/sqlplus -s user/pass @sqlscript`
if [ "$VALUE" = 'ERROR TYPE 1' ];
then
code to process here;
else
code to process here;
fi
the sql script:
set pagesize 0
set feedback off
set verify off
set heading off
set echo off
var out_status varchar2(30)
exec sp_tester(:out_status);
print out_status
exit;
the stored procedure:
procedure sp_tester (out_status out varchar2) is
begin
select 'ERROR TYPE 1' from dual;
end;
Thanks again everyone.
- « Previous
-
- 1
- 2
- Next »
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP