Configuring DB connectors - SAP HANA

Studio enables you to use the database connectors to connect to your relational databases like MySQL, PostgreSQL and Microsoft SQL, MongoDB and so on.

SAP HANA is an in-memory, column-oriented, relational database management system developed and marketed by SAP SE. Studio provides the SAP HANA connector that enables you to carry out primary function to store and retrieve data as requested by the applications.

Configuring SAP HANA connector

To add a third-party DB connector, under Studio > Connectors, click (+) Connector and select the SAP HANA connector.

Enter the Connector Name.

Add the exact connection string if you have it or enter the connection parameters that are required, namely Host and database name. You have optional parameters for username, password, and port. You can also enable further action to Connect using SSL and Whitelisting IP.

Once these configurations are added Test the connection. If the authentication is successful you would get the response accordingly. You can now click to Save your configuration.

Adding queries to the Database connector

Now that you have configured the connector you will find it under the Custom Database connectors list. Now to fetch data or undertake any other action, click Add query option available once your connection is ready.

Here you can add your queries - simple as well as complex ones. To the right-hand side of the screen, you can see the list of tables from the database. You can expand the tables to view the fields from the table.

You can provide a name to the query . Enter your query and click press Ctrl + enter to run the query. The rows returned from the table are shown in the Response section.

To use a dynamic variable in a query, you simply need to put it into double Curly brackets. You can add a sample value to test your query before saving it. When using the connector queries the dynamic variables would have to be linked to the respective control for further run-time functioning.

Using SAP HANA connector

Fetch all rows

Now let us take a simple example to fetch all rows from the table auth_permission and display in a table grid control. In this case, you simply need to add the SQL query as per the SAP HANA syntax.
Add the query and run to verify the output. Once done Save the query.

Now whenever you need to get data from SAP HANA you can use the connector query anytime within your apps. Now if you want to display the author permissions in a tablegrid control you simply need to add the connector to the app and then bind the connector in the respective control’s properties (tablegrid in this case).

Provide the input values if any and click Finish. Now when you want to bind data to your table grid control you need to add the connector from Studio Console > Connectors. Under Data > Bind Data, select Connector and select the respective connector name and then select the columns you want to display. You can transform the connector response or apply conditional formatting as required.

Display 10 records

Now here consider an example where we want to find the author’s permission from the table but want to display only the first 10 records. So we would now need to add pagination by making use of the LIMIT clause to limit the number of rows returned. Now in another scenario, if you want to provide a dynamic input as to the number of rows you can assign the value accepted from the form and send it as a variable to the query.

For example, on the form you can add a dropdown control which gives the user the option to select the number of records to display. Pass this value to the connector at runtime. In the example below the limitrows variable is a dynamic variable and we are passing the value using the Keywords. Here we have specified numberofrecordstodisplay which is the dropdown control. So the value selected would be set for the Limit clause of the Query.

In this example form, to bind the fetched data to the Tablegrid control, select the Connector from the list of connectors available. You can see in the Custom Formula the BINDAPI formula which you can customize further if you want to format how your data would be displayed in the TableGrid.

Now whenever you run the app, you can enter the initials in the text control and the table grid would display only those rows from the table that match the condition given.

Using the DB Connector for PostgreSQL is similar to using it with other databases like MS SQL, MS SQL and so on. You can make use of the Queries to fetch data as well bind data such that you can undertake the insert, update, delete actions as well.