Julian wrote :
Hello,
> When I create db procedure without OUT parameter and I try to
>update/insert some records within this dbprocedure, this one don't
>return number of updated/inserted records.
>For example:
> CREATE TABLE test_table (
> test_value VARCHAR(50)
> )
> CREATE DBPROCEDURE update_test_value (
> IN in_old_test_value VARCHAR(50),
> IN in_new_test_value VARCHAR(50)
> )
> AS
> TRY
> UPDATE test_table SET
> test_value = :in_new_test_value
> WHERE test_value = :in_old_test_value;
> CATCH
> IF $RC <> 0 THEN STOP ($RC, $ERRMSG);
> This is the java code that call db procedure. There is expected
>number of updated records in the variable iUpdateCount but allways 0 is
>returned.
> CallableStatement updateStatement = null;
> int iUpdateCount = 0;
> updateStatement = dbConnection.prepareCall(strUpdateCall);
> updateStatement.setString(1, strOldValue);
> updateStatement.setString(2, strNewValue);
> // here is the bug in SAP DB, if there is called stored
>procedure without
> // output parameters, there is not returned number of updated
>records
> iUpdateCount = updateStatement.executeUpdate();
> Db procedure returns correct number of updated records when I add
>an OUT paramete into the db procedure.
> Is this feature of the SAP DB procedures or bug?
With the current state of implementation it is not intended that a call of a
db-procedure returns the number of
affected rows implicitly. This is because you may have more than one update statement
inside your db-procedure,
which row count should be returned then ?
Maybe we should introduce a new system variable $ROWCOUNT which allows to set the row
count explicitly :
CREATE DBPROCEDURE update_test_value (
IN in_old_test_value VARCHAR(50),
IN in_new_test_value VARCHAR(50)
)
AS
TRY
UPDATE test_table SET
test_value = :in_new_test_value
WHERE test_value = :in_old_test_value;
$ROWCOUNT = $COUNT;
CATCH
IF $RC <> 0 THEN STOP ($RC, $ERRMSG);
Regards,
Thomas
--
Thomas Anhaus
SAP DB, SAP Labs Berlin
[EMAIL PROTECTED]
http://www.sapdb.org/
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general