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:
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:
#!/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