PHP ODBC to HANA/SAP returns less results than expected

Issue

I’m having a very strange problem. I have written a HanaSQL query in HANA Studio. Everything is fine, it returns all results i expected – about 43k.

Then I have written an odbc connection in php, which will connect to SAP. Everything works fine until then.

Now I am executing the SAME query from HANA in my script and get much less results than I expected, sometimes 3, sometimes 148 or 1.3k results.

What is the problem:
The problem could be, that there is too much data in the query. It is really a big flat table I need to read (81 columns, was not made by me, i have no choice then). So, if I am selecting less columns, I’ll receive more results. Let’s say I just select the ItemCode/SKU from the product, then I receive All 43k products, which is OK. Now I am adding a second column, lets say “name” which is mostly longer than the SKU of a product. Now I’m receiving just 13k items. When I’m adding a third column “description” I just receive 1.3k results. I think the size of the result is the problem.

Other funny fact: I have written earlier a tool in C#, which also uses the SAME odbc connection to HANA. When I am using the same query like in my php script, i am also getting, like in HANA, ALL results.

I am working on a windows machine, so i thought “OK, maybe XAMPP is the problem”. So i tried the same thing on my own second machine, installed with Linux mint (GUI) and also on a server here at work with Ubuntu 16. I always get the same results, when I am using php.

So I think the problem can’t be the connection to hana (it can’t, because its working fine in the C# tool). Also it is not the query, because I,m getting all results I expected in HANA and the C# Tool. Also it is not an OS problem, it was tested on 3 different systems and always different php versions (also 5 and 7 was tested separately).

I also checked some odbc-settings in php. Maybe I have forgotten something?

There is – currently – also no alternative to switch to c#. Background: We want to read the products from SAP and want to import them into a new PIM system. A few properties will remain in SAP, so it is not just the initial import, but also a comparison later between 2-3 properties from SAP, which we then everytime need to import in the PIM software. And NO, we can NOT also move these fields to the PIM software later – it is not wanted.

I was searching the problem all the day yesterday, but I could not find anyone else with this problem. I hope someone can help me.

Does anyone also had this problems with php?
I really hope someone can help me.

Solution

In order to avoid the problem of interrupted result set transfer, the parameter CHAR_AS_UTF8=true has to be set in the ODBC-DSN.

See also Why does sqlQuery from SAP HANA using RODBC return no data if request 18 or more rows.

Answered By – Lars Br.

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published