Error while running Procedure in shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error while running Procedure in shell script
# 1  
Old 07-11-2016
Error while running Procedure in shell script

Hi All,

I am running the below proc in unix by connecting through sqlplus and the procedure is completing successfully. But when i am trying to run through shell scripting by using function. I am getting the error as follows. Please guide me where I am going wrong.
Code:
#!/bin/sh
opera ()
{
DECLARE
param NVARCHAR2 (20) := 'NULL';
BEGIN
opat.Opat_Data_Archive_Pkg.archive_dataSet_versions ('g692245', param);
END;
/
}
sqlplus OPERA_DATA/tanstaaflUAT115@TNYOPA57 opera

output:
Code:
./coast.sh: line 5: syntax error near unexpected token `('
./coast.sh: line 5: `param NVARCHAR2 (20) := 'NULL';'


Last edited by rbatte1; 07-12-2016 at 08:39 AM.. Reason: Added CODE tags round output for clarity
# 2  
Old 07-11-2016
Just guessing: opera is an SQL function, not a shell function. You need to declare it within sqlplus...
# 3  
Old 07-11-2016
still no luck.
# 4  
Old 07-12-2016
Post your modified code, and how you call your script. And, of course, what error messages you get in your modified code.
# 5  
Old 07-12-2016
Would you be better with a here document?

A very quick hack at this would be:-
Code:
#!/bin/sh

sqlplus OPERA_DATA/tanstaaflUAT115@TNYOPA57 <<EOSQL
DECLARE
param NVARCHAR2 (20) := 'NULL';
BEGIN
opat.Opat_Data_Archive_Pkg.archive_dataSet_versions ('g692245', param);
END;
/
EOSQL


Is that useful?
Robin
# 6  
Old 07-13-2016
Hi rbatte1,

when run the script now I am not seeing any errors. But it's stopping after the below. Can you please help me here.

Code:
./vijay.sh
 SQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 13 08:36:38 2016
 Copyright (c) 1982, 2011, Oracle.  All rights reserved.
 
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle Label Security,
OLAP, Data Mining and Real Application Testing options
 SQL>   2    3    4    5    6



Moderator's Comments:
Mod Comment Please use code tags as required by forum rules!

Last edited by RudiC; 07-13-2016 at 04:01 PM.. Reason: Added code tags.
# 7  
Old 07-13-2016
See post#4.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Why i can't execute the procedure in shell script?

i have the following code inside a shell script .prog in oracle server when i call the program DBMS_OUTPUT.PUT_LINE(x_return_status|| ln_rep_req_id); will return 0 , it is very strange , i try to submit the concurrent request in oracle , and it can successfully executed, what am i missing ? i... (1 Reply)
Discussion started by: feilhk
1 Replies

2. Solaris

Error during running sqlplus command from shell script in Solaris

I am using following code to connect to oracle database from solaris shell script. which will try thrice to connect the database ...at the 4rth atempt it will exir=t. count=0 while ; do sqlplus -s $usrname/$password@dbSID <<-EOF | tee $logfile WHENEVER OSERROR EXIT 9; WHENEVER SQLERROR... (4 Replies)
Discussion started by: millan
4 Replies

3. Shell Programming and Scripting

SP2-0642 error while executing procedure from shell script

hi all, i have a unix script where i am calling a database procedure from it. while executing the procedure i am getting an error: but when i tried to call the same procedure manually then it ran successfully, i goggled this issue and found timezone.dat file missing at... (0 Replies)
Discussion started by: lovelysethii
0 Replies

4. Shell Programming and Scripting

Launcher Error: while running shell script

Hi Experts, I have a shell script which used to take oracle database backup, which is scheduled in a tidal scheduling tool. however it is throwing an error while triggering the job and getting below error in the log file. "Launcher Error: This is an internal function" shell script is... (1 Reply)
Discussion started by: UnniVKN
1 Replies

5. Shell Programming and Scripting

Run stored procedure from shell script

Hello all, I am trying to run stored procrdure from shell script which takes one argument. And also I want to verify in the script whether the script executed successfully. However the Stored procedure is not running from shell script. Manually if I run it update the data in the table. Can... (29 Replies)
Discussion started by: PriyaSri
29 Replies

6. Shell Programming and Scripting

Executing Procedure from shell script..

Hello, I created a sql file to create a Procedure, and it was successfully created. I created a sql file to execute the procedure, and it did without any errors, but i dont see the data been updated. The Execute procedure.sql script is: BEGIN set serveroutput on size 1000000 execute... (5 Replies)
Discussion started by: msrahman
5 Replies

7. Shell Programming and Scripting

error running shell script

how can i fix this error. + f_Delete resync-printers.ksh: test: argument expected lpadmin: Expected printer or class after '-x' option! resync-printers.ksh: test: argument expected + f_Create resync-printers.ksh: trying to execute a function (20 Replies)
Discussion started by: ggoliath
20 Replies

8. Shell Programming and Scripting

`(' unexpected error when running a shell script in AIX

Hi, We are moving from linux to AIX servers, and as a result testing our scripts on the new platform. When I run one of our scripts, I get the following error message: ./branchDataUpdate.sh: syntax error at line 21 : `(' unexpected Following is an extract from the script: ...... ........ (1 Reply)
Discussion started by: dawgfather80
1 Replies

9. Shell Programming and Scripting

Error while running as shell script

Storage_Unit=`du -h /var/spool/cron/root|awk '{print $1}'|sed -e "s/^.*\(.\)$/\1/"` If then Size=`du -h /var/spool/cron/root|awk '{print $1}'|sed 's/.\{1\}$//'` for Size_rounded_number in $(printf %.0f $Size); do ROUNDED_Size=$Size_rounded_number done if #setting a threshold of say... (1 Reply)
Discussion started by: proactiveaditya
1 Replies

10. Shell Programming and Scripting

error in running shell script in cron

#!/bin/bash CLASSPATH=. #CLASSPATH=${CLASSPATH}:${INSTALL_PATH}home/squidlog/CopyFile.java CLASSPATH=${CLASSPATH}:${INSTALL_PATH}usr/java/latest/lib/*.jar javac CopyFile.java echo "CLASSPATH=$CLASSPATH" #home/wbiadmin/JRE1.4.2/j2re1.4.2_15/bin/java CopyFile /usr/bin/java... (3 Replies)
Discussion started by: sari
3 Replies
Login or Register to Ask a Question