#!/bin/sh
# This script returns the number of rows updated from a function
echo "The execution is starting ....."
sqlplus -silent $UP <<EOF
set serveroutput on
set echo off
set pagesize 0
VAR no_rows_updated NUMBER;
EXEC :no_rows_updated :=0;
DECLARE
CURSOR c_update is
SELECT * FROM BELK_BOOKS FOR UPDATE OF AUTHOR_NAME;
BEGIN
FOR REC IN c_update
LOOP
UPDATE Belk_Books
SET AUTHOR_NAME='ASFAKUL'
WHERE CURRENT OF c_update;
:no_rows_updated:=c_update%ROWCOUNT;
--no_rows_updated:=no_rows_updated+1;
END LOOP;
Commit;
--SELECT c_update%ROWCOUNT INTO no_rows_updated from Dual;
--no_rows_updated:=c_update%ROWCOUNT;
--DBMS_OUTPUT.PUT_LINE(no_rows_updated);
EXCEPTION
WHEN OTHERS THEN
:no_rows_updated:=SQLCODE;
ROLLBACK;
END;
/
exit :no_rows_updated ;
EOF
error_exit=$?
if [ $error_exit -ne 0 ]; then
echo "There was an error or 0 rows updated"
else
echo "The number of rows updated is : $error_exit"
fi
here is the code I am trying to run , please help