• No se han encontrado resultados

El Buscapié, un “periódico para todos”, y otras publicaciones defensoras de la mujer

CAPÍTULO 4 PRELUDIOS DEL DISCURSO FEMINISTA EN PUERTO RICO: SU REFLEJO EN

4.3. El Buscapié, un “periódico para todos”, y otras publicaciones defensoras de la mujer

Use the SQLScript editor, which includes debugging capabilities, to build SQLScript procedures.

You can also use the Navigator in the Modeler perspective to build procedures, but there are no debugging capabilities. You should only use this method:

● If you need to develop a procedure using a local table type as an input or output parameter. A local table type is created within the Navigator procedure tool and for only the current procedure. If you can use a global table type, then use the SQLScript Editor.

● If you need to edit a procedure previously created in the Navigator that contains table type parameters.

Related Links

SAP HANA SQL Reference SAP HANA SQLScript Reference SAP HANA R Integration Guide

SAP HANA Business Function Library (BFL) Reference SAP HANA Predictive Analysis Library (PAL) Reference Creating Procedures

7.1 Editing SQLScript

The SAP HANA SQLScript editor allows you to create, edit and activate procedures.

Before you begin working in the SAP HANA SQLScript editor, open the SAP HANA Development perspective and do the following:

● Create a development workspace. For more information, see Creating a Repository Workspace [page 39].

● Checkout a package. For more information, see Working with the Repository [page 27] .

Note: After checking out a package that contains active procedures, you can modify and debug the procedures.

● Create and share a project. For more information, see Using SAP HANA Projects [page 37].

.

Note: You can also share your project after you create your procedure.

To write and edit a procedure in the SAP HANA SQLScript editor, perform the following steps:

1. After you have created your workspace and your project, go to the Project Explorer view in the SAP HANA Development perspective , right-click on the file name, select New, and select File. The New File wizard will appear.

2. Enter or select the parent folder and enter the file name using the following naming convention

<filename>.procedure. Choose Finish. The icon shows that your procedure is created locally. Choose Save.

Your procedure will open containing the default Create Procedure template. In the Properties view, you will see the properties of your procedure, such as Access Mode, Name and Language. You can also change the default schema that this procedure is using.

Note: You can also create a folder first and add a file. Right-click on the project name, select New, and select Folder. The New Folder wizard will appear. Enter or select the project, enter the folder name, and choose Finish.

3. To share your project, right-click on the project name, select Team, and select Share Project. The Share Project wizard will appear. Choose Finish. The icon shows that your procedure is not committed and not activated.

4. You can begin writing your code inside your new procedure and save it locally. The syntax is checked simultaneously and is highlighted. Auto-completion of the syntax appears as you type; press Ctrl + Spacebar to get a list of relevant SQLScript statements.

Note: You can only write one stored procedure per file. The file name and the procedure name must be the same.

5. To commit your new procedure or make changes to an existing one, first save it, right-click on the procedure, select Team, and select Commit. Your procedure is now synchronized to the repository as a design-time object and the icon shows that your procedure is committed .

Caution: The design-time presentation of the procedure is currently in XML format that you must not edit.

6. When you have finished writing your procedure and you are ready to activate it, right-click on the procedure, select Team, and select Activate. Your procedure is created in the catalog as a runtime object and the icon shows that your procedure is activated . This will allow you and other users to call the procedure and debug it.

If an error is detected during activation, an error message will appear in the Problems view.

Note: You can also activate your procedure at the project and folder level.

Related Links

SAP HANA Development Perspective [page 25]

SAP HANA Repository Packages and Namespaces [page 43]

In SAP HANA, a package typically consists of a collection of repository objects, which can be transported between systems. Multiple packages can be combined in a delivery unit (DU).

About SAP HANA SQLScript SAP HANA SQL Reference

SAP HANA System Tables and Monitoring Views Reference

7.2 Debugging SQLScript

The SAP HANA SQLScript debugger allows you to debug and analyze procedures. In a debug session, your procedures will be executed in a serial mode, not in parallel (not-optimized). This allows you to test the correctness of the procedure logic and is not for evaluating the performance.

Before you begin using the SAP HANA SQLScript debugger, you must activate your procedures and they must belong to a project on your local work station. For more information, see Editing SQLScript.

To debug a procedure in the SAP HANA SQLScript debugger, perform the following steps:

1. Open the Debug perspective in the SAP HANA studio and select the procedure you want to debug by clicking on the relevant tab in the Editor view.

2. Double-click on the left vertical ruler to add breakpoints to your procedure. You can see a list of all of the breakpoints in the Breakpoints view.

From the Breakpoints view, you can:

○ Deselect specific breakpoints or skip all of them.

○ Delete a specific breakpoint or delete all.

○ Double-click on a breakpoint to see which line it belongs to in the Editor view.

○ See the status of the breakpoint:

○ Pending

○ Valid

○ Invalid

3. To create a debug session you must first create a debug configuration. Choose and select Debug Configurations.... The Debug Configurations wizard will appear.

Note: The current debug configuration allows you to debug any stored procedure that is opened in the editor. Therefore, you do not have to create a new debug configuration for every procedure you want to debug.

4. Double-click SQLScript Procedure, enter a name, choose Apply, and choose Close.

Note: If you want to start debugging your procedure, choose Apply and choose Debug.

5. To start your debug session, choose and select your debug configuration. The debug session will begin and you will see the status of the session in the Debug view. The status of a breakpoint may change after the server has validated it. The breakpoint position might change if it is placed on an invalid line where the debugger cannot stop. The debugger will stop at the first breakpoint and the session will be suspended until you resume it.

If your run is successful, the valid status will appear next to the breakpoints in the Breakpoints view.

Note: You must set breakpoints in the lines you want to break at and resume the session again.

You can evaluate your local scalar and table variables in the Variable view. The view shows the values of the scalar variables and the number of rows in each table.

6. To view the content of the tables listed in the Variable view, right-click on the table name and select Open Data Preview. The results will appear in the Preview view. This view will automatically close when you resume your debug session.

The session will be terminated when you reach the end of the procedure run.

7.3 Developing Procedures in the Modeler Editor

To create procedures, use the SQLScript Editor, as described in Editing SQLScript [page 159].

If you need to create procedures with local table types, that is, table types created only for the procedure, perform the steps described in this section.

1. On the Quick Launch tab page, choose Procedure.

If the Quick Launch page is not open, go to Help Quick Launch . 2. Enter a name and description for the procedure.

3. For unqualified access in SQL, select the required schema from the Default Schema dropdown list.

Note:

○ If you do not select a default schema, while scripting you need to provide fully qualified names of the catalog objects that include the schema.

○ If you specify a default schema, and write SQL such as

select * from myTable

, the specified default schema is used at runtime to refer to the table.

4. Select the package in which you want to save the procedure.

5. Select the required option from the Run With dropdown list to select which privileges are to be considered while executing the procedure.

Note:

There are two types of rights, as follows:

Definer's right: If you want the system to use the rights of the definer while executing the procedure for any user.

Invoker's right: If you want the system to use the rights of the current user while executing the procedure.

6. Select the required access mode as follows:

Access Mode Purpose

Read Only Use this mode to create procedures for fetching table data.

Read Write Use this mode to create procedures for fetching and

updating table data.

7. Select the language in which you are writing the procedure.

8. Choose Finish.

9. In the function editor pane, write a script for the function using the following data types:

○ Table or scalar data types for input parameters.

○ Table data types for output parameters.

Note: You can only write one function in the function body. However, you can refer to other functions.

10. Choose File Save .

11. Activate the procedure using one of the following options in the toolbar:

Save and Activate: Activate the current procedure and redeploy the affected objects if an active version of the affected object exists. Otherwise only the current procedure gets activated.

Save and Activate All: Activate the current procedure along with the required and affected objects.

Note: You can also activate the current procedure by selecting the procedure in the Navigator view and choosing Activate in the context menu. For more information about activation, see Activating Objects [page 132].

8 Defining Web-based Data Access

SAP HANA extended application services (SAP HANA XS) provide applications and application developers with access to the SAP HANA database using a consumption model that is exposed via HTTP.

In addition to providing application-specific consumption models, SAP HANA XS also host system services that are part of the SAP HANA database, for example: search services and a built-in Web server that provides access to static content stored in the SAP HANA repository.

The consumption model provided by SAP HANA XS focuses on server-side applications written in JavaScript and making use of a powerful set of specially developed API functions. However, you can use other methods to provide access to the data you want to expose in SAP HANA. For example, you can set up an ODATA service or use the XML for Analysis (XMLA) interface to send a Multi-dimensional Expressions (MDX) query. This section describes how to set up a service that enables you to expose data using OData or XMLA.

8.1 Data Access with OData in SAP HANA XS

In SAP HANA Extended Application Services (SAP HANA XS), the persistence model (for example, tables, views, and stored procedures) is mapped to the consumption model that is exposed to clients - the applications you write to extract data from the SAP HANA database.

You can map the persistence and consumption models with OData, a resource-based Web protocol for querying and updating data. An OData application running in SAP HANA XS is used to provide the consumption model for client applications exchanging OData queries with the SAP HANA database.:

You can use OData to enable clients to consume authorized data stored in the SAP HANA database. OData defines operations on resources using RESTful HTTP commands (for example,

GET

,

PUT

,

POST

, and

DELETE

) and specifies the URI syntax for identifying the resources. Data is transferred over HTTP using either the Atom (XML) or the JSON (JavaScript) format.

Applications running in SAP HANA XS enable accurate control of the flow of data between the presentational layer, for example, in the Browser, and the data-processing layer in SAP HANA itself, where the calculations are performed, for example, in SQL or SQLScript. If you develop and deploy an OData service running in SAP HANA XS, you can take advantage of the embedded access to SAP HANA that SAP HANA XS provides; the embedded access greatly improves end-to-end performance.

8.1.1 OData in SAP HANA XS

OData is a resource-based web protocol for querying and updating data. OData defines operations on resources using HTTP commands (for example,

GET

,

PUT

,

POST

, and

DELETE

) and specifies the uniform resource indicator (URI) syntax to use to identify the resources.

Data is transferred over HTTP using the Atom or JSON format:

Note: OData makes it easier for SAP, for partners, and for customers to build standards-based

applications for many different devices and on various platforms, for example, applications that are based on a lightweight consumption of SAP and non-SAP business application data.

The main aim of OData is to define an abstract data model and a protocol which, combined, enable any client to access data exposed by any data source. Clients might include Web browsers, mobile devices,

business-intelligence tools, and custom applications (for example, written in programming languages such as PHP or Java);

data sources can include databases, content-management systems, the Cloud, or custom applications (for example, written in Java).

The OData approach to data exchange involves the following elements:

● OData data model

Provides a generic way to organize and describe data. OData uses the Entity 1 Data Model (EDM).

● OData protocol

Enables a client to query an OData service. The OData protocol is a set of interactions, which includes the usual REST-based create, read, update, and delete operations along with an OData-defined query language.

The OData service sends data in either of the following ways:

○ XML-based format defined by Atom/AtomPub

○ JavaScript Object Notation (JSON)

● OData client libraries

Enables access to data via the OData protocol. Since most OData clients are applications, pre-built libraries for making OData requests and getting results reduces and simplifies work for the developers who create those applications.

A broad selection of OData client libraries are already widely available, for example: Android, Java, JavaScript, PHP, Ruby, and the best known mobile platforms.

● OData services

Exposes an end point that allows access to data in the SAP HANA database. The OData service implements the OData protocol (using the OData Data Services runtime) and uses the Data Access layer to map data between its underlying form (database tables, spreadsheet lists, and so on) and a format that the requesting client can understand.

8.1.2 OData Service Definitions

The OData service definition is the mechanism you use to define what data to expose with OData, how, and to whom. Data exposed as an OData collection is available for analysis and display by client applications, for example, a browser that uses functions provided by an OData client library running on the client system.

To expose information by means of OData to applications using SAP HANA XS, you must define database views that provide the data with the required granularity. Then you create an OData service definition, which is a file you use to specify which database views or tables are exposed as OData collections.

Note: SAP HANA XS currently supports OData version 2.0, which you can use to send OData queries (using the http

GET

method). Language encoding is restricted to UTF-8.

An OData service for SAP HANA XS is defined in a text file with the file suffix

.xsodata

, for example,

OdataSrvDef.xsodata

. The file must contain at least the entry

service {}

, which would generate a completely operational OData service with an empty service catalog and an empty metadata file. However, usually you use the service definition to expose objects in the database catalog, for example: tables, SQL views, or calculation rules.

In the OData service-definition file, you can use the following ways to name the SAP HANA objects you want to expose by OData:

● Repository objects

Expose an object using the object's repository (design-time) name in the OData service-definition file. This method of exposing database objects by OData has the advantage that the OData service is automatically updated if the underlying repository object changes.

● Database objects

Expose an object using the object's database catalog (runtime) name (along with the schema name). The support for database objects is mainly intended for existing or replicated objects that do not have a repository design-time representation.

Note: Although both declaration methods are supported, the recommended method is to use the repository name of the object(s) you want to expose using OData.