0

I connect to BBDD HANA from PHP code. The connector is unixodbc. (table have spanish characters)

When try to select records, if any field have special characters (ex: euro character) they skip fetch and log in odbc:

DIAG [S1000] [SAP AG][LIBODBCHDB SO][HDBODBC] General error;-10427 Conversion of parameter/column (8) from data type NVARCHAR to ASCII failed

The config odbc.ini

[hanadb]
Driver = /usr/sap/hdbclient/libodbcHDB.so
ServerNode = 172.17.xx.xx:31015

(i try to add this line, without any change)

DriverUnicodeType=1
DriverManagerEncoding = UTF-8
Locale = es_ES
characterset=UTF8
IANAAPPCODEPAGE=2026

The code in php

$result = odbc_exec($link,"SELECT * FROM ZIF_TCONDW ");

while($datos=odbc_fetch_array($result)) {
    $query=sprintf("INSERT INTO condiciones values
   {...}

fields with text:

Pedidos de 701€ a 1200€

Crash, and in the trace file:

DIAG [S1000] [SAP AG][LIBODBCHDB SO][HDBODBC] General error;-10427 Conversion of parameter/column (8) from data type NVARCHAR to ASCII failed

I try too convert type in select sentence

$result = odbc_exec($link,"SELECT LIFNR,ZONA,POSCOND,LEFT(STRTOBIN(CONCEPTO,'UTF-8') ,400) AS CONCEPTO, CONDICION ,ORDEN,AEDAT,AEUHR,AENAM FROM ZIF_TCONDW "); 

or

$result = odbc_exec($link,"SELECT LIFNR,ZONA,POSCOND,base64_encode(CONCEPTO) AS CONCEPTO, base64_encode(CONDICION) AS CONDICION ,ORDEN,AEDAT,AEUHR,AENAM FROM ZIF_TCONDW ");

Without change.

1 Answers1

1

This is a problem that occurs when the ODBC driver tries to hand over Unicode data to your client variables. You might want to set the CHAR_AS_UTF8 = true connection option to avoid that. See SAP HANA Client Interface Programming Reference.

Lars Br.
  • 9,949
  • 2
  • 15
  • 29