Skip to Content
0

QUERY with SDK in SAP HANA

Sep 28, 2017 at 01:18 PM

91

avatar image
Former Member

Hello Experts,

I am doing a query from the SAP SDK to SAP HANA, I use Visual Studio 2015 with C #.

The error that gives me is when I make a WHERE, that does not bring me anything and I effectively check that it exists in sap, since I do the same query but without WHERE and it shows me.

screenshot-1.png (64.8 kB)
screenshot-2.png (48.4 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Edy Simon Sep 29, 2017 at 05:05 AM
0

oRecordSet.DoQuery("SELECT * FROM OITM WHERE OITM.\"ItemName\" = 'ABCDEFG'");

Share
10 |10000 characters needed characters left characters exceeded
Ralph Oliveira
Oct 05, 2017 at 03:42 PM
1

Just a comment.

As a best practice you should never query tables on HANA directly from your addon. This might lead to bad performance and other issues.

Instead the query should be encapsulated in Calculation View (preferred Graphic) and then your addon can call this CV.

Ideally the view would be exposed via a Odata service.


Show 2 Share
10 |10000 characters needed characters left characters exceeded

That’s an interesting recommendation. I never heard of that. What is the reasoning behind it and are there maybe any documentation for that?

Thanks, Lars

0

Creating a Graphic CV will help you to build more standardized (and consequently optimized) queries. In the case above, it would have avoided the Select *. Which is much painful to HANA than other databases (due to the column storage). It is also a significant part of our process of pushing logic down to the database.

Adding a web service layer on top has several advantages in comparison with the regular DB driver approach. Such as security, DB Load reductions, scalability and others. It also makes your app more lightweight, critical in these days where we are porting solutions to cloud environments.

To get more details, please check: Encapsulating Database Access: An Agile 'Best Practice'

0
DIEGO LOTHER Sep 28, 2017 at 01:25 PM
0

Hi Jesus,

Did you try use in your code, the same query that you use in query manager with the where clause?

Hana have differences of SQL Server. One is that the fields should be envolved with ".

A sample:

SELECT TOP 10 * FROM OITM WHERE "ItemName" = 'your item name'

Hope it helps.

Kind Regards,

Diego Lother

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Sí, ya la consulta en el gestor de hana sap y si funciona.


Como en la primera imagen el ItemCode está entre comillas y no funciona tampoco

0

Hi Jesus:

This:

SELECT TOP 10 * FROM OITM WHERE 'ItemName' = 'your item name'

is different from this:

SELECT TOP 10 * FROM OITM WHERE "ItemName" = 'your item name'

In the first case hana will compare the string 'ItemName' with 'your item name'.

In the second case hana will compare the value from ItemName field with 'your item name'

For all of your fields, you need use " instead '

Hope it helps.

Kind Regards,

Diego Lother

0