XMLTYPE.XMLQUERY Returns Wrong Results (Doc ID 1590651.1)

Last updated on FEBRUARY 21, 2017

Applies to:

Oracle Database - Enterprise Edition - Version 11.2.0.3 and later
Information in this document applies to any platform.

Symptoms

Following select query returns wrong results:

select XMLQuery('/objects' passing xmltype(c) returning content) from xdbbug.test2;

Query output: In good file lua function VerifyCreditCardNumber starts from line 234. In bad file it starts from line 135. It is right.
But in bad file it starts again from 225, 390, 621, 918, 1281, 1710 lines. There are parts of this lua fuction were been inserted
into its body several times. It is not right because in good file and source xml this function starts only once.

function VerifyCreditCardNumber(text, strict)

for _,val in pairs({"Â ", "\r", "\n", "\t", "", "", ",", ";", "%.", "%?", "

!", ":"}) do

text = string.gsub(text, val, "")

end

if text:sub(1,1) == " " then text = text:sub(2) end

if text:sub(-1) == " " then text = text:sub(1, -2) end

if text:sub(-1) < '0' or text:sub(-1) > '9' then text = text:sub(1, -2) end

local separators = {}

local digits = {}

local result = ""

local separators_count = 0

local pos = 0

for character in text:gmatch(".") do

if character >= '0' and character <= '9' then

table.insert(digits, (character - '0'))

result = result..character

else

if string.len(result) % 4 ~= 0 then return "" end

separators_count = separators_count + 1

separators[character] = 0

local i = 0

for _,__ in pairs(separators) do i = i + 1 if i > 1 then return "" e

nd end

end

 

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms