在SAP HANA中有一些语句无法在script中直接执行。可以用一些work around来完成相应的功能。

1) roll back和commit:

直接执行会报syntax error,可以用变量的方式执行:

DROP PROCEDURE EXCEPTION_HANDLING_TEST;

/* Creating a Procedure for testing Predefined Exception Handling */

CREATE PROCEDURE EXCEPTION_HANDLING_TEST (OUT Status_Code INTEGER ) AS

BEGIN

DECLARE  var_commit  VARCHAR(100) := ‘COMMIT’;

DECLARE var_rollback VARCHAR(100) := ‘ROLLBACK’ ;

DECLARE EXIT HANDLER FOR SQLEXCEPTION

BEGIN

EXEC (:var_rollback);

INSERT INTO “ERROR_LOGS” ( error_no,error_cd,error_msg ) VALUES ( <schemaname>.SNO.NEXTVAL,::SQL_ERROR_CODE,::SQL_ERROR_MESSAGE );

Status_Code := 1;

END;

INSERT INTO EMPLOYEE_TEST VALUES (1);

INSERT INTO EMPLOYEE_TEST VALUES (1); — Again inserting 1 will result in unique violation error

EXEC (:var_commit);

Status_Code := 0;

END;

2) create user

报错:

“CREATE USER is not allowed in SQLScript….”

参照KBA 1967438,用exec的方式执行。

3) BACKUP CATALOG DELETE ALL BEFORE BACKUP_ID :backup_id WITH BACKINT

报错:

“Error creating procedure;sql syntax error: System management statement

is not allowed in SQLScript: line 5 col 1 (at pos 213) at

qp_gram.y:36851″

参照KBA 1967438,用exec的方式执行。

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply