什么是SAP HANA Database Procedure(数据库过程)

SAP HANA数据库给开发人员提供了一种编程方式的选择,能够在数据库层直接编写应用逻辑。这些应用逻辑可以实现在所谓的数据库过程(database procedure)里,实现语言为SAP HANA SQLScript.

The SAP HANA database comes with a variety of programming options for application logic at the database level. The database procedures (which are used to implement the application logic) can be written as queries that follow the SAP HANA database SQLScript syntax.

我们可以把数据库过程简单地类比成一个只能进行数据库读写相关方面的函数,能接收任意多个输入参数和定义输出参数,存放数据库操作的结果。参数的类型既可以是标量式类型,比如integer, double, varchar等,也可以是table类型。

Database procedures can have multiple input parameters and output parameters; these are either of scalar (such as integer, double, varchar) or table type.
Using ADT tools, you can implement HANA database procedures by means of…

使用ABAP Development Tool, 我们可以选择两种不同的方式来实现数据库过程。第一种,即本文标题提及的AMDP, 第二种为Xxx, 不在本文讨论范围之内。

AMDP, 顾名思义,即在ABAP层进行HANA数据库过程的实现和生命周期(lifecycle)的管理。开发人员通过位于ABAP层的ADT, 编写HANA SQLScript作为AMDP的实现体,以此达到在ABAP层直接消费HANA数据库层原生功能的目的。

The basic idea of AMDP is to manage HANA procedures and their lifecycle inside the ABAP server. To allow native consumption of HANA features from within the ABAP layer, the HANA database procedure language SQLScript has been integrated into the ABAP stack.

具体到实现环节,在ABAP层内何种类型的开发对象里编写HANA SQLScript呢?答案仍然是ABAP类的方法内,只不过是在一种声明了特定接口的ABAP类,用AMDP特定的ABAP关键字修饰的方法内。继续沿用ABAP类方法来开发AMDP, 使得传统ABAP应用开发人员除了熟悉HANA SQLScript语法外,无需付出额外的学习成本。这种特殊的ABAP类方法,作为HANA SQLScript的承载容器,使得AMDP同其他普通的ABAP开发对象一样,采取统一的ABAP传输管理,生命周期管理,代码缺陷和升级管理方式。

AMDP is implemented in ABAP class methods (so-called AMDP methods) that serve as a container for SQLScript code. This approach offers many significant advantages:

  • It enables the shipment of AMDP in the same way as any other ABAP development object (lifecycle management)

  • It allows you to implement and ship corrections for AMDPs, just like it is possible for ABAP classes, including SAP Note support (supportability and extensibility).

除了AMDP之外,数据库过程代理也是另一种HANA数据库过程的实现方式。这种方式首先在HANA repository里创建一个HANA原生的数据库过程,再到ABAP层创建一个代理指向前者,在ABAP应用里通过使用该代理对象消费HANA仓库里的原生数据库过程。同AMDP相比,这种方式需要在HANA层进行原生开发,因此在实际的开发中,SAP更推荐使用AMDP.

Using an implemented database procedure in the HANA repository, you have the option to create a corresponding proxy that is stored in the ABAP repository. The proxy represents the HANA database procedure interface in relation to ABAP programs.
CautionABAP-Managed Database Procedures is recommended instead of calling SQLScript procedures using database procedure proxies. AMDP is the replacement technology for database procedure proxies. The use of database procedure proxies will only be required in the particular case where a secondary database connection is used to access the SAP HANA database, which is not the central database of the AS ABAP (side-by-side scenario).

你可能感兴趣的:(Jerry,Wang的原创SAP技术文章,HANA,ABAP)