SAP HANA 8. SQLScript Basic 之 Create an SQLScript Procedure with SELECT Statement

1、新建文件NewFile 创建get_bp_addresses_by_role_sql.procedure

 

2Local Table Type中定义本地类型

/*
You can create new table types and use them as input and output parameters in a procedure.
The table types must be defined using SQL syntax, for example:
CREATE TYPE <Type Name> AS TABLE (<filed Name1> <Filed Type1>, <filed Name2> <Filed Type2>,...).
*/
create type tt_bp_addresses as table (
PartnerId nvarchar(10),
PartnerRole nvarchar(3),
EmailAddress nvarchar(255),
CompanyName nvarchar(80),
AddressId nvarchar(10),
City nvarchar(40),
PostalCode nvarchar(10),
Street nvarchar(60)
)

 
 

SAP HANA 8. SQLScript Basic 之 Create an SQLScript Procedure with SELECT Statement_第1张图片

 

3SQLScript Tab页中代码创建Procedure

CREATE PROCEDUREget_bp_addresses_by_role_sql (
    in partnerrole nvarchar(3),
    out bp_addresses tt_bp_addresses
)
LANGUAGESQLSCRIPT
SQLSECURITY INVOKER
READSSQL DATA AS
BEGIN
/*****************************
Writeyour procedure logic
 *****************************/
 bp_addresses =
selecta."PartnerId", a."PartnerRole", a."EmailAddress",a."CompanyName",
a."AddressId",b."City", b."PostalCode", b."Street"
from"SAP_HANA_EPM_DEMO"."sap.hana.democontent.epm.data::businessPartner"as a
inner join"SAP_HANA_EPM_DEMO"."sap.hana.democontent.epm.data::addresses"as b
ona."AddressId" = b."AddressId"
wherea."PartnerRole" = :partnerrole;
END;


 

4TeamCommit& Activate之后,在SQL Console中调用代码,生成procedure,如下图所示:

call"_SYS_BIC"."WorkShop.sessiona.00.models/get_bp_addresses_by_role_sql"(
partnerrole =>'02', bp_addresses => ? )
 
 

SAP HANA 8. SQLScript Basic 之 Create an SQLScript Procedure with SELECT Statement_第2张图片

你可能感兴趣的:(sql,HANA,SAP,内存计算,列存储)