SAP HANA SPS10- SQLScript
-
Upload
sap-technology -
Category
Technology
-
view
455 -
download
5
Transcript of SAP HANA SPS10- SQLScript
1© 2014 SAP AG or an SAP affiliate company. All rights reserved.
SAP HANA SPS 10 - What’s New? SQLScript
SAP HANA Product Management June, 2015
(Delta from SPS 09 to SPS 10)
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 2Public
Roadmap SAP HANA SQLScriptSummary
Today
SAP HANA Studio
Semantic Code Completion
Web Based Development
Workbench
New Editor
New Debugger
Language Features
Table parameter definitions
Table variable definitions
Autonomous Transactions
Planned Innovations (SPS 10)
COMMIT/ROLLBACK Support
Header Only Procedures/Functions
SQL Inlining Hints
Multiple output in scalar UDF assignment
Table Types for Table Variable
Declarations
Anonymous Blocks
Web Based Development Workbench
Semantic Code Completion
Design-Time artifact debugging
This is the current state of planning and may be changed by SAP at any time.
Future Direction (SPS 11 and
beyond)
SQLScript v3 performance
enhancements
GIS Support
Table cell access(read/modify)
Move from Repository to GIT
HDI: HANA Deployment
Infrastructure
Containers for schema free content
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 3Public
SQLScript – What’s New in SPS 10?
Tooling
Code Completion in Web-based Dev Workbench
Design-Time Debugging in Web-based Dev Workbench
Language
Commit/Rollback
Anonymous Blocks
Header-Only Procedure/Function
SQL Inlining Hints
Multiple Scalar Variable Assignment
Table Type for Table Variable Declarations
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 4Public
SQLScript – What’s New in SPS 10Code Completion
Code completion in web-
based development
workbench
• CTRL+SPACE
• Keyword/statement code
completion
• Semantic code completion
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 5Public
SQLScript – What’s New in SPS 10Design-Time Artifact Debugging
Design-Time artifact
debugging from web-based
development workbench
• Breakpoints in design-
time artifact
.hdbprocedure
• “Invoke Procedure”
button
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 6Public
SQLScript – What’s New in SPS 10Commit/Rollback
COMMIT/ROLLBACK
• Supported in procedures only, not supported for scalar or table UDFs
• COMMIT command commits the current transaction and all changes before the COMMIT
command
• ROLLBACK command rolls back the current transaction and undoes all changes since the last
COMMIT
• Transaction boundary is not tied to the procedure block, so if there are nested procedures that
contain COMMIT/ROLLBACK then all statements in the top-level procedure are affected.
• If dynamic SQL was used in the past to execute COMMIT and ROLLBACK statements, it is
recommended to replace all occurrences with the native command because they are more
secure.
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 7Public
SQLScript – What’s New in SPS 10Commit/Rollback(Cont.)
COMMIT/ROLLBACK
• The first and third INSERT
statements affect the productLog
table, but not the second since it
was rolled back.
• With the first COMMIT, the first
transaction is written to
persistence, and a new transaction
is started
• By triggering ROLLBACK, all
changes in the second transaction
are reverted, and a new
transaction is started
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 8Public
SQLScript – What’s New in SPS 10Anonymous Blocks
Anonymous Blocks
• Executable DML statement which
can contain imperative and
declarative statements
• No lifecycle handling(e.g.
CREATE/DROP), no catalog object
• No parameters or container specific
properties such as language, or
security mode
• Supports complete SQLScript
language
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 9Public
SQLScript – What’s New in SPS 10Header Only Procedures/Functions
Header Only Procedures/Functions
• When creating a procedure, all nested procedures need to exist beforehand
• Create procedures/functions with minimum metadata first using the HEADER ONLY extension
• Inject the body of the procedure/function by using the ALTER PROCEDURE statement
CREATE PROCEDURE <proc_name> [(<parameter_clause>)] AS HEADER ONLY
ALTER PROCEDURE <proc_name> [(<parameter_clause>)]
[LANGUAGE <lang>]
[SQL SECURITY <mode>]
[DEFAULT SCHEMA <default_schema_name>]
READS SQL DATA AS
BEGIN
<procedure_body>
END;
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 10Public
SQLScript – What’s New in SPS 10SQL Inlining Hints
SQL Inlining Hints
• Used to explicitly enforce or block the
inlining of SQL Statements within
SQLScript
• Depending on the scenario, execution
performance could be improved
Example: Block Statement-Inlining
CREATE PROCEDURE procNoInline ( OUT tab2 tt_tab )
LANGUAGE SQLSCRIPT READS SQL DATA AS
BEGIN
tab = SELECT * FROM T WITH HINT (NO_INLINE);
--> Statement will not be inlined into tab2
tab2 = SELECT * from :tab;
END;
Example : Enforce Statement-Inlining
CREATE PROCEDURE procInner (IN tab1 tt_tab, OUT tab2 tt_tab )
LANGUAGE SQLSCRIPT READS SQL DATA AS
BEGIN
tab2 = SELECT I FROM :tab1 WITH HINT (INLINE);
--> Statement will be inlined into the statement of
--> variable table2 of procedure procCaller
END;
CREATE PROCEDURE procCaller (IN table1 tt_tab,
OUT table2 tt_tab)
LANGUAGE SQLSCRIPT READS SQL DATA AS
BEGIN
call procInner (:table1,outTable);
table2 = select I from :outTable;
END;
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 11Public
SQLScript – What’s New in SPS 10Multiple Scalar Variable Assignments
Multiple Scalar Variable Assignments
• Prior to SPS 10, multiple parameter
assignment for scalar UDFs was not
supported. You were forced to do the
assignment via SELECT statement
SPS 10 assign multiple outputs of Scalar UDF to multiple scalar variables
CREATE PROCEDURE proc(IN a int, IN b int,
OUT x int, OUT y int)
LANGUAGE SQLSCRIPT READS SQL DATA AS
begin
(x,y) = inner_func1(a,b);
end;
It is also possible to only assign a single output
CREATE PROCEDURE proc(IN a int, IN b int,
OUT x int, OUT y int)
LANGUAGE SQLSCRIPT READS SQL DATA AS
begin
x = inner_func1(a,b).x;
y = inner_func1(a,b).y;
end;
SPS 09 consuming multiple result via SELECT statement
CREATE PROCEDURE proc(IN a int, IN b int,
OUT x int, OUT y int)
LANGUAGE SQLSCRIPT READS SQL DATA AS
begin
select inner_func1(a,b).x, inner_func1(a,b).y
into x,y from dummy;
end;
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 12Public
SQLScript – What’s New in SPS 10Table Types for Table Variable Declarations
Table Type for Table Variable Declarations
• Reference a table type in DECLARE statement
• Must contain runtime object name including schema
CREATE PROCEDURE test_table_type( )
LANGUAGE SQLSCRIPT READS SQL DATA AS
BEGIN
declare lt_tab "SAP_HANA_EPM_NEXT"."sap.hana.democontent.epmNext.data::MD.Products";
lt_tab = select * from "SAP_HANA_EPM_NEXT"."sap.hana.democontent.epmNext.data::MD.Products";
select * from :lt_tab;
END;
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 13
How to find SAP HANA documentation on this topic?
SAP HANA Platform SPS
What’s New – Release Notes
Installation
– SAP HANA Server Installation Guide
Security
Administration
– SAP HANA Administration Guide
Development
– SAP HANA Developer Guide
References
– SAP HANA SQL Reference
• In addition to this learning material, you find SAP HANA documentation on
SAP Help Portal knowledge center at http://help.sap.com/hana_platform.
• The knowledge center is structured according to the product lifecycle: installation, security, administration,
development. So you can find e.g. the SAP HANA Server Installation Guide
in the Installation section and so forth …
© 2015 SAP SE or an SAP affiliate company. All rights reserved.
Thank you
Contact information
Rich Heilman
SAP HANA Product Management
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 15Public
© 2015 SAP SE or an SAP affiliate company. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an SAP affiliate company.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE (or an SAP affiliate
company) in Germany and other countries. Please see http://global12.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and notices.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP SE or its
affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or SAP affiliate company products and
services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as
constituting an additional warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop
or release any functionality mentioned therein. This document, or any related presentation, and SAP SE’s or its affiliated companies’ strategy and possible future
developments, products, and/or platform directions and functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time
for any reason without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. All forward-
looking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are cautioned not to place
undue reliance on these forward-looking statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.