Error when calling sybase stored proc from shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error when calling sybase stored proc from shell script
# 1  
Old 02-03-2010
Error when calling sybase stored proc from shell script

Hi,
I am writing a script that needs to call a stored proc which would update a column in a table based on a condition.
I need to also capture the number of rows updated.
However, When I execute the script I keep getting this error:
./test_isql.sh: syntax error at line 33: `end of file' unexpected

I have listed my stored proc and shell script below. Please help. I have been stuck a couple of days on this!!

If I remove the part with the isql, the script works fine!!

This is my stored proc:

Code:
 
IF OBJECT_ID ('dbo.UpdateForecastRunning_pr') IS NOT NULL
 DROP PROCEDURE dbo.UpdateForecastRunning_pr
GO
/*
* $Header:$
* 
*/
/*$Log:$
 * 
*/
CREATE PROC UpdateForecastRunning_pr
        
AS
  
BEGIN
    UPDATE System SET VersionNbr = '2.19.6'
    WHERE VersionNbr = '2.19.5'
  
    RETURN @@ROWCOUNT
END

GO

And this is my shell script:

Code:
 
#!/bin/sh
. /global/Shrc
# Usage
if [ $# -ne 3 ]
then
echo "Usage test_isql.sh Username Password Server"
exit 1
fi
echo $1
echo $2
echo $3
USER=$1
PASSWORD=$2
SERVER=$3
#isql -U $USER -S DEVEL -P monkeypod -i updatesystem.sql -o system.DEVEL
trycount="0"
ROWSUPDATED=0
echo "Before While begins"
while [ "$ROWSUPDATED" -lt 1 ] && [ "$trycount" -lt 10 ]
do
echo "Starting while loop"
ROWSUPDATED=isql -D$icasb  -U $USER -S DEVEL -P monkeypod -o system.DEVEL << EOF
EXEC icasb..UpdateForecastRunning_pr
EOF
trycount=`expr $trycount + 1`
echo "Procedure returned: $trycount"
done
exit 0

Thank You
Karthik
# 2  
Old 02-03-2010
Code:
ROWSUPDATED=isql -D$icasb  -U $USER -S DEVEL -P monkeypod -o system.DEVEL << EOF
EXEC icasb..UpdateForecastRunning_pr
EOF

this is causing syntax error.

if you really want to capture the db o/p into the variable, use `` or $()

Code:
ROWSUPDATED=`isql -D$icasb  -U $USER -S DEVEL -P monkeypod -o system.DEVEL << EOF
EXEC icasb..UpdateForecastRunning_pr
EOF`

# 3  
Old 02-03-2010
Hi,
Thanks for the reply. That took care of the error, but still the RowsUpdated value is not getting updated. Its showing up as a null string when I echo it out:

Code:
 
echo "Rows Updated: $ROWSUPDATED"

The output is
Code:
 
Rows updated:<blank>

# 4  
Old 02-04-2010
what is the output of the proc when you execute it on the sybase prompt?
if possible, post the output.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sybase Stored Proc call from UNIX script.

Hi, I am new to shell scripting and Sybase database i need a help that i try to execute a SYBASE stored procedure from a Unix shell script and wanna write the output of the SP into a Text File.somehow i try to find a solution but whwn i try to run the script i am not getting the output file with... (1 Reply)
Discussion started by: Arun619
1 Replies

2. How to Post in the The UNIX and Linux Forums

Calling a Sybase Stored procedure from a UNIX Script

Hi, I am new to shell scripting and Sybase database i need a help that i try to execute a SYBASE stored procedure from a Unix shell script and wanna write the output of the SP into a Text File.somehow i try to find a solution but whwn i try to run the script i am not getting the output file with... (1 Reply)
Discussion started by: Arun619
1 Replies

3. Post Here to Contact Site Administrators and Moderators

Calling Sybase Stored proc from UNIX Shellscript.

Hi, I am new to shell scripting and Sybase database i need a help that i try to execute a SYBASE stored procedure from a Unix shell script and wanna write the output of the SP into a Text File, somehow i tried to find a solution but when i try to run the script i am not getting the output file with... (1 Reply)
Discussion started by: Arun619
1 Replies

4. Shell Programming and Scripting

Calling Oracle stored procedure from ksh script

Friends, I'm newbie with ksh so wanting some help.... 1. I'm trying to call oracle stored procedure from ksh script by taking variable value from runtime, feed into script and execute procedure. 2. Put name1 and name2 value from script run replacing $3 & $4 I'm trying to put name1 in... (4 Replies)
Discussion started by: homer4all
4 Replies

5. UNIX for Dummies Questions & Answers

Calling Shell script Error

Hi All, I need to call a script in another server(Say B).So I logged in my local Machine(say A)using putty and given these command ssh root@hostname cd home\oracle sh script.sh. This is working perfectly.But when I have those command in a shell script and placed in my local... (2 Replies)
Discussion started by: Nivas
2 Replies

6. Shell Programming and Scripting

Execute stored procedure through script in sybase database and store the output in a .csv file

Hi, I have a sybase stored procedure which takes two input parameters (start_date and end_date) and when it get executed, it gives few records as an output. I want to write a unix script (ksh) which login to the sybase database, then execute this stored procedure (takes the input parameter as... (8 Replies)
Discussion started by: amit.mathur08
8 Replies

7. Shell Programming and Scripting

Executing Shell Script from Within a Sybase Stored Proc

Greetings, I need to make an open server call to a shell script from inside a Sybase Stored procedure. Coul any one please provide a sample code? TIA (0 Replies)
Discussion started by: rajpreetsidhu
0 Replies

8. Shell Programming and Scripting

Calling an Oracle Stored Procedure from Unix shell script

hai, can anybody say how to call or to execute an oracle stored procedure in oracle from unix... thanks in advance.... for ur reply.... by, leo (2 Replies)
Discussion started by: Leojhose
2 Replies

9. Shell Programming and Scripting

Calling stored procedure from shell script

HI, I have a similar problem to thread 18264, only I couldn't get it to work. https://www.unix.com/showthread.php?t=18264 I have a stored procedure which is called by a shell script program. When I run the stored procedure alone or through the shell script, it works fine with output text... (3 Replies)
Discussion started by: dorisw
3 Replies

10. Shell Programming and Scripting

calling stored procedure from shell script.

Hi All, This is a very starnge problem I am having. I have a shell script that calls a stored procedure. Here's my code in shell script: sqlplus "userid/pwd" @file.sql and file.sql has the following statement: exec my_storedProc; Now, when I execute my shell script, nothing... (2 Replies)
Discussion started by: priyamurthy2005
2 Replies
Login or Register to Ask a Question

Featured Tech Videos