如何返回HANA存储过程中受影响的行数?

时间:2022-02-12 16:52:09

How does one return the number of rows affected from an insert or update statement while inside a SAP HANA stored procedure?

在SAP HANA存储过程中,如何返回插入或更新语句中受影响的行数?

In oracle one would use sql%rowcount but I can't find an equivalent for HANA in their documentation?

在oracle中,我会使用sql%rowcount,但我在他们的文档中找不到HANA的等价物?

For example:

CREATE PROCEDURE procedure_name (p_input)
LANGUAGE SQLSCRIPT AS
BEGIN
   define c integer;
   insert into some_table values (somevalues);
   c := sql%rowcount;
END

UPDATE:

I found the answer on an SAP thread finally. You can run this statement after the insert or update to get the rowcount:

我终于在SAP线程上找到了答案。您可以在插入或更新后运行此语句以获取rowcount:

SELECT ::ROWCOUNT into L_C FROM DUMMY;

1 个解决方案

#1


7  

Not trying to steal internet points, but this should have an answer that's not just in the description of the question. To select row count, use the following:

不试图窃取互联网点,但这应该有一个答案,不仅仅是在问题的描述。要选择行计数,请使用以下命令:

SELECT ::ROWCOUNT INTO someVariable FROM DUMMY;

DUMMY is a special keyword in HANA and is used to select variables vs selecting from a table. You cannot simply SELECT ::ROWCOUNT INTO someVariable in HANA.

DUMMY是HANA中的特殊关键字,用于选择变量与从表中选择。您不能简单地在HANA中SELECT :: ROWCOUNT INTO someVariable。

#1


7  

Not trying to steal internet points, but this should have an answer that's not just in the description of the question. To select row count, use the following:

不试图窃取互联网点,但这应该有一个答案,不仅仅是在问题的描述。要选择行计数,请使用以下命令:

SELECT ::ROWCOUNT INTO someVariable FROM DUMMY;

DUMMY is a special keyword in HANA and is used to select variables vs selecting from a table. You cannot simply SELECT ::ROWCOUNT INTO someVariable in HANA.

DUMMY是HANA中的特殊关键字,用于选择变量与从表中选择。您不能简单地在HANA中SELECT :: ROWCOUNT INTO someVariable。