• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

Creating Functions in SAP HANA

CREATE FUNCTIONS (deprecated syntax)

Syntax

Name data – type

[,….] [LANGUAGE <LANGY>]

Begin

End

Descriptions

Create a table functions – say function  is SQL script can have a list of input and act put parameters click each parameter is marked using the keywords (IN/OUT/INOUT).  Input and output parameters must be explicitly typed (i.e no un typed tables are supported)

INOUT parameters can only be of salon type one can use the deprecated replace function to modify a function definition which maintaining the function signature and DROP function to resolve it. This statement is reserved for potential later use to define user defined functions

Create procedure (new syntax)

Syntax

CREATE PROCEDURE [schema.] name [({In/OUT/IN out}

Faram – name data – type C, …]}]

[LANGUAGE <LANG>] [SQL SECURITY <MODE>]

[READS SQL DATA [WITH RESULT VIEW <VIEW – NAME>]]

AS BEGIN
…….
end

At TekSlate, we offer resources that help you in learning various IT courses. We avail both written material and demo
       video tutorials. To gain in-depth knowledge and be on par with  practical experience, then explore 
       SAP HANA Training in Chennai.

Description

CREATE PROCEDURE replaces CREATE FUNCTION (With out Return clause). In the Inter face of a procedure only SQL types and table types are supported.

The implementation language is by default SQL Script. It is good practice to define the language in all procedure definitions. Other implementation languages are supported but are not covered in this guide

One can specify the security mode. Privileges are always checked with the privileges of the definer of a procedure when the procedure is created. With security mode “definer”, which is the default, execution of the procedure is there performed with privileges of the define of the procedure. The other alternative is mode “ in worker”. In this case privileges are checked at runtime with the privileges of the caller of the function please note that analyze teal privileges are checked regardless of the security mode. See SAP HANA security guide referenced at the beginning of the document for details.

Optionally, a procedure can be tagged as read only procedure using READS SQL DATA. This marks a procedure as being from of side – effects. One factor to be considered here is that neither DDL our DML statecrafts are allowed its body, and only other read – only procedures can be called by the procedure. The advantage to this definition is that certain optimizations are only available for read only procedures.

If a read – only procedure box exactly one table output parameter, a result view can be specified as it was previously available for table functions. The name of the result view is no longer bound to a static name scheme but can be any valid SQL identifier. For back word compatibility reasons the old static name scheme will be only supported for procedures that are generated with the deprecated

CREATE FUNCTION SYNTAX

CREATE PROCEDURE Proe with result view (in id int,, out OI customer)

LANGUAGE SQLSCRIPT READS SQL DATA WITH RESULT VIEW PROVIES AS BEGIN

01= SELECT * FROM CUSTOMER WHERE CUST_id

= : ID :

END:

Normally, procedures can only be executed via the call statement. Using with result mew it is possible to query the result of a procedure as part of a SQL statement

Example

SELECT * FROM PROCVIEW WITH PARAMETERS

(‘place holder’ = (‘$$ id$$, ‘s’))

You have t use DROP and create to modify the definition of a procedure

Replace Function (Deprecated Syntax)

Syntax

REPLACE FUNCTION [SCHEMA] NAME ([IN|OUT|INOUT}

PARM-NAME DATA – TYUPE (,—])

BEGIN

—-

END

Description

This statement is used to modify a function definition while maintaining the signature.

Please migrate to a procedure lusted of using this statement. This statement is reserved for potential later use with use defined functions

Drop function (deprecated syntax)

Syntax

Drop function [schema.] name [cascade]

Description

Delete a function definition from the database catalog. If cascading drop is defined dependent objects will also be dropped; other wise, they are invalidated. This statement is reserved for potential later use to drop a user defined function.

For an Indepth knowledge on SAP HANA, click on below

Summary
Review Date
Reviewed Item
Creating Functions in SAP HANA
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Creating Functions in SAP HANA"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Site Disclaimer, Copyright © 2016 - All Rights Reserved.

    Support


    Please leave a message and we'll get back to you soon.

    I agree to be contacted via e-mail.