Skip to Content
avatar image
Former Member

QUERY with SDK in SAP HANA

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)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Sep 29, 2017 at 05:05 AM

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

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 05, 2017 at 03:42 PM

    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.


    Add comment
    10|10000 characters needed characters exceeded

    • 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'

  • Sep 28, 2017 at 01:25 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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