Hi
In below query i am getting error -
1). [SAP AG][LIBODBCHDB DLL][HDBODBC] General error;339 invalid number: not a valid number string '10, 10' at implicit type conversion 'Backend scheduling job' (OBSJ) (at pos 97)
SQL
WHEN T1."TransType" = '1470000049' THEN
(
SELECT STRING_AGG(TO_NVARCHAR(OL."Code"), ', ')
FROM OITM A11
JOIN OLCT OL ON OL."Code" = A11."Location"
WHERE A11."ItemCode" IN (
SELECT DISTINCT A0."ItemCode"
FROM ACQ1 A0
WHERE A0."DocEntry" = T1."CreatedBy"
AND A0."ObjType" = '1470000049'
)
)Thanks

Amira BedhiafiRank #601 · 4K reputationPosted Jun 3, 2025, 4:12 AM EDT
Hello Ramco,
If
OL."Code"is of a numeric type (INTEGER) and you're doing:STRING_AGG(OL."Code", ', ')it tries to do string aggregation without converting the number to a string first, which may work but if you explicitly wrap it in
TO_NVARCHAR, and somewhere the result is expected to be numeric it fails.Try explicitly casting the result to NVARCHAR outside the
CASEas well:WHEN T1."TransType" = '1470000049' THEN ( SELECT STRING_AGG(TO_NVARCHAR(OL."Code"), ', ') FROM OITM A11 JOIN OLCT OL ON OL."Code" = A11."Location" WHERE A11."ItemCode" IN ( SELECT DISTINCT A0."ItemCode" FROM ACQ1 A0 WHERE A0."DocEntry" = T1."CreatedBy" AND A0."ObjType" = '1470000049' ) )And if you’re doing something like this:
CASE ... WHEN ... THEN (subquery) ELSE (some number) ENDThen this will also fail because all
THENandELSEclauses in aCASEmust return the same type. IfELSEis a number andTHENis a string, you'll get an implicit conversion error.