Sponsored Content
Top Forums Shell Programming and Scripting unix capture oracle function error Post 302421588 by dips_ag on Friday 14th of May 2010 11:20:04 PM
Old 05-15-2010
Hi durden_tyler,

Quote:
Finally, as a side note - your Oracle function code should not have OUT parameters. An Oracle function returns one and only one value, the datatype of which must be specified by the RETURN clause. Parameters passed to an Oracle function should be IN parameters, and you do not have to specify the keyword "IN".
Actually this is just a sample function in real there would be an IN parameter and I can forgo with OUT parameter but not the SELECT clause; the function will have to use an SELECT clause as it's going to query a table based on the IN parameter.

As you suggested I modified the Oracle function without OUT parameter now it looks like:

Code:
create or replace
function test_fn
RETURN varchar2
IS
test_date VARCHAR2(100);
BEGIN

select to_char(sysdate,'DD-MON-YY') into test_date from dual;   
return test_date ;
END test_fn;

But still the problem persists.

Quote:
Can you copy/paste the exact Terminal session that shows what exactly you executed and what exactly you encountered as a result ?
Here's it is. I deliberately gave a wrong funciton name (test_fn1)(in blue) NOTE: I created a "testing" directory and touched "file1", "file2" & "file3" which (in red) can be seen listed when error occurs.

Code:
$ ./calltest_fn.ksh
var test_var:=test_fn1; calltest_fn.ksh file1 file2 file3 ERROR at line 4: ORA-06550: line 4, column 11: PLS-00201: identifier 'test_fn1' must be declared ORA-06550: line 4, column 1: PL/SQL: Statement ignored

Quote:
(I am unable to reproduce the "listing-of-files-in-current-directory" behavior, but then my environment - Cygwin Bash -> Windows sqlplus -> Oracle server on WinXP may be drastically different from yours.)
Yeah even I am perplexed! I am surely doing something silly. Here's the m/c on which I am running the script.
Code:
$ uname -a
Linux <machine name> 2.6.9-89.ELsmp ####################


The script calltest_fn.ksh is as follows:
Code:
#!/usr/bin/ksh

#set -x

var=`sqlplus -s <<EOF
user/pass@DB
WHENEVER SQLERROR EXIT FAILURE
WHENEVER OSERROR  EXIT FAILURE
set serveroutput on
set feedback off
set linesize 250
DECLARE
test_var varchar2(100);
BEGIN
test_var:=test_fn1;
dbms_output.put_line(test_var);
END;
/
quit;
EOF`

echo var $var

-dips
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capture Oracle return code in shell script

I am using the following code in my shell script list=`sqlplus -s $user/$pwd@$dbms<<EOF WHENEVER SQLERROR EXIT SQL.SQLCODE set pagesize 0 feedback off verify off heading off echo off select * from control_tbl where src_nm=$3 and extrct_nm=$4; exit SQL.SQLCODE; EOF` ERROR=$?... (1 Reply)
Discussion started by: Vikas Sood
1 Replies

2. Solaris

how to capture oracle export log while running as background process

I ran the Oracle 9i export command from a terminal to export out a big table using "exp andrew/password file=andrew.dmp log=andrew.log" From the terminal I can see that the export is running as there is some output from the oracle export job. The export job is not complete yet. When i go check... (4 Replies)
Discussion started by: hippo2020
4 Replies

3. Shell Programming and Scripting

How to capture value in shell variable from oracle sql?

Hi Friends, Do someone know how to capture value in a shell variable from oracle sql? Requirement : In a table we want to count the number of records and want to pass this value to a shell variable where it can be manipulated later. In ksh shell we open oracle connection from sqlplus. For... (1 Reply)
Discussion started by: sourabhsharma
1 Replies

4. Shell Programming and Scripting

how to capture oracle function returning 2 values in unix

i have an oracle function which returns two values, one is the error message if the function encounters anything and another one which returns a number i need to capture both and pass it on to unix shell script how to do it (2 Replies)
Discussion started by: trichyselva
2 Replies

5. Shell Programming and Scripting

Need to capture error of sybase sql in unix

Hi Gurus, I am very new in Unix, I have 1 script, in which I am truncating the table , then BCP the data in Sybase table, and then loading the data from sybase table to sybase table. every thing is working fine, but the problem is with Error. I made some hanges in my insert statement so... (1 Reply)
Discussion started by: aksar
1 Replies

6. Shell Programming and Scripting

Need to capture error of sybase isql in unix

Hi Gurus, I am very new in Unix, I have 1 script, in which I am truncating the table , then BCP the data in Sybase table, and then loading the data from sybase table to sybase table. every thing is working fine, but the problem is with Error. I made some hanges in my insert statement so... (3 Replies)
Discussion started by: aksar
3 Replies

7. Shell Programming and Scripting

Capture rows for a column in file from delete sql -Oracle

Hi, This may not be the right forum but i am hoping someone knows an answer to this. I have to capture rows for a column that was deleted. How can i do that without having to write a select query? delete from myschema.mytable where currentdatetimestamp > columnDate this should delete 5... (4 Replies)
Discussion started by: jakSun8
4 Replies

8. Shell Programming and Scripting

How to capture system() function output in variable

How to capture system() function output in awk variable and the print that awk variable..... (8 Replies)
Discussion started by: bharat1211
8 Replies

9. Homework & Coursework Questions

How to Dynamically Pass Parameter to plsql Function & Capture its Output Value in a Shell Variable?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: 2. Relevant commands, code, scripts, algorithms: #! /bin/ksh v="ORG_ID" ... (2 Replies)
Discussion started by: sujitdas2104
2 Replies

10. Red Hat

Unable to capture value from function

Hi Experts, Am writing a code which need to check for the previous day date and pickup the file as per the previous day date. Problem: Why variable "YDATE" is empty ? O/S: RHEL 5.6 Shell: BASH Desired O/P: ls -lrt /opt/test/user/atsuser.NHU/out/demon.08272017 When I checked the... (3 Replies)
Discussion started by: pradeep84in
3 Replies
All times are GMT -4. The time now is 02:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy