Return rows from Oracle package


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Return rows from Oracle package
# 1  
Old 04-20-2009
Return rows from Oracle package

I need help . I am not getting anything back from my setup. I have defined an oracle package which I am calling from within my sql call, but is returning no rows. If I run my sql from sqlplus works find, does not work whe I try to run from UNIX shell script

My korn script test.ksh

#!bin/ksh
set -x
#
#export ORACLE_HOME=/unixsxxx/apps/oracle/dist/xxxx
export ORACLE_SID=xxxxxx
export ORAENV_ASK=NO
export ORA_USERNAME=xxxxxx
export ORA_PASSWORD=xxxxxxx
export logfileTMP=/xxxxxxx/home/help.log
export TNS_ADMIN=/usr/local/bin/oracle
export PATH=$PATH:$TNS_ADMIN
. oraenv
sqlplus-S ${ORA_USERNAME}\/${ORA_PASSWORD}@${ORACLE_SID} <<-! 2>/dev/null 1>>$logfileTMP
@/xxxxx/home/help.sql
exit
/
****************************************************

help.sql is explained below

set serveroutput on size 1000000
SET AUTO on;
SET LINESIZE 500;
SET NEWPAGE none;
SET SPACE 0;
SET TRIMSPOOL on;
SET PAGESIZE 0;
SET ECHO off;
SET FEEDBACK off;
spool /home/xxxx/marina.txt;
declare
type rcursor is ref cursor;
emptab rcursor;
emprec PS_CIBC_ENV_VARS%rowtype;
begin
help_package.proc1('XXXXXX',emptab);
loop
fetch emptab into emprec;
exit when emptab%notfound;
IF emprec.COL_WIDTH = 2 then
dbms_output.put_line('EXPORT ' || emprec.LABEL_ID || '= ' || emprec.STRING_TEXT || ';');
else
dbms_output.put_line('EXPORT ' || emprec.LABEL_ID || '= ' || emprec.STRING_TEXT || emprec.STRING_ID || ';');
end if;
end loop;

end;
spool off;
# 2  
Old 04-20-2009
Code:
#!bin/ksh
set -x
#
#export ORACLE_HOME=/unixsxxx/apps/oracle/dist/xxxx
export ORACLE_SID=xxxxxx
export ORAENV_ASK=NO
export ORA_USERNAME=xxxxxx
export ORA_PASSWORD=xxxxxxx
export logfileTMP=/xxxxxxx/home/help.log
export TNS_ADMIN=/usr/local/bin/oracle
export PATH=$PATH:$TNS_ADMIN
. oraenv
sqlplus-S ${ORA_USERNAME}\/${ORA_PASSWORD}@${ORACLE_SID} <<EOF 2>/dev/null 1>>$logfileTMP
@/xxxxx/home/help.sql
exit
/
EOF

I changed your -! to EOF so you can see they have to match on both sides of a here document. The "last" EOF has to be in column 1 of the script. My /bin/ksh parser does not like -! as a here doc delimiter -- ie., it does not see it properly.
# 3  
Old 04-20-2009
Still no results

runs successfully bit not results are spooled.
# 4  
Old 04-20-2009
Can you try it without the 'here statement'? Not sure if you need it at all in this situation:

Code:
sqlplus -s "${ORA_USERNAME}/${ORA_PASSWORD}@${ORACLE_SID}" @/xxxxx/home/help.sql

echo $?
...

# 5  
Old 04-20-2009
Get this message

sqlplus -s "${ORA_USERNAME}\/${ORA_PASSWORD}@${ORACLE_SID}"@/unixsxxx/xxxxx/xxxenv.sql
echo $?

ksh: sqlplus: not found
+ echo 127
127
+ exit
# 6  
Old 04-20-2009
put it back to where i had it

but still no output
last part returned
+ 0<<
@/unixs317/home/cibcenv.sql
echo 0
exit
/
# 7  
Old 04-21-2009
Thanks everyone

I figured it ou at last. was suggesful in generating my list.

thanks all for the help. Hopefully one day I too can provide assistance.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Variables passed to awk to return certain rows

Hi Forum. I have the following test.txt file and need to extract certain rows based on "starting position", "length of string" and "string to search for": 1a2b3d 2a3c4d ..... My script accepts 3 parameters: (starting col pos, length to search for, string to search for) and would like to... (4 Replies)
Discussion started by: pchang
4 Replies

2. UNIX for Dummies Questions & Answers

Trying to configure DNS using BIND package in Oracle Linux 6.6

Version: Oracle Linux 6.6 I am trying to set up DNS for forward and reverse lookups. I am new to BIND package. I have installed the following packages. bind (includes DNS server, named) bind-utils (utilities for querying DNS servers about host information) bind-libs (libraries... (0 Replies)
Discussion started by: kraljic
0 Replies

3. Shell Programming and Scripting

How to call Oracle package in shell file?

How to call oracle package in shell file in my shell file, I have Export SQL FILE =$Home_dir select.sql if I want to add call two function in package how can I do it :( (2 Replies)
Discussion started by: Hscript
2 Replies

4. Red Hat

How to call Oracle package through shell script?

Hey i have a package in oracle to validate file mask. can i call it in through shell script . if yes , how Thanks (1 Reply)
Discussion started by: ramsavi
1 Replies

5. Programming

SQL Syabse - return rows where certain value changes

Hi, I need help selecting rows from a table when a certain column value (City) changes. In this example of table rows: ID City Updated_By Updated_Date 99999 PARIS JOHN 04/05/2010 11:28:09.813 99999 PARIS JOHN 04/05/2010 11:32:05.240 99999 PARIS JOHN 04/05/2010 11:32:20.750 99999 PARIS... (1 Reply)
Discussion started by: Renato2011
1 Replies

6. Shell Programming and Scripting

Calling oracle package Unix from shell scripts.

Hi, Can anyone tell me how to call a oracle package from a Unix shell script? I want to pass some input parameters to package and it will return me the output which I want to use further in my shell script. I want to know the way to capture the output values in my shell script. Please send some... (1 Reply)
Discussion started by: anil029
1 Replies

7. Shell Programming and Scripting

getting return value from oracle function

So, in Oracle (11gR2) on aix I have a function like: CREATE OR REPLACE function COMMON.t2(var1 in varchar2, vari in number,var2 in out number) return number as begin insert into korisnik_temp(kor_inicia, kor_opisno) values(1, var1); var2:=0; return var2; exception when... (12 Replies)
Discussion started by: bongo
12 Replies

8. Shell Programming and Scripting

invoke oracle package error?

My sh scripts is : sqlplus -S "user/pwd@server" <<!! SET SQLPROMPT exec IN_PROC_TEST; !! It prompt 'PL/SQL procedure successfully completed.' but not execute actually :mad: I run this procedure in sqlplus, no problem and I also could execute simple DDL in this sh script, but why... (2 Replies)
Discussion started by: andrewknight
2 Replies

9. Shell Programming and Scripting

return number of rows selected

Hi all, i am doing a perl script to read from a db. I am able to retrieve the rows, but i am unable to return the number of rows selected. i tried $selectedrows = $sth->numrows; i got the error msg: Can't locate object method "numrows" via package "DBI::st" i changed it to $selectedrows =... (7 Replies)
Discussion started by: new2ss
7 Replies
Login or Register to Ask a Question