I am trying to parse XML using PostgreSQL.
XML contains null-value. The expected type of column is “int”.
But postgres treats the value as empty (not null) string.
with data as (
select
'<root>
<test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<int_value xsi:nil="true"/>
</row>
</test>
</root>'::xml val)
select int_value
from data x,
xmltable(
'/root/test/row'
passing val
columns int_value int
)
I am expected to get query result with one field “int_value” of type “int” with null-value.
Actual result is error message:
ERROR: invalid syntax for type integer: “”.
New contributor
Valerian Kanzharadze is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.