Skip to content

Commit 1050356

Browse files
yahondaclaude
andcommitted
Fix XMLType parameter handling on Oracle 12c+
Oracle 12c+ reports XMLType parameters with data_type "XMLTYPE" instead of "UNDEFINED". Handle both values in add_argument and add_return_variable so the XMLTYPE wrapper SQL is generated correctly. This fixes the XMLType tests that were skipped since issue #114. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 64e7db9 commit 1050356

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

lib/plsql/procedure_call.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ def add_argument(argument, value, argument_metadata = nil)
240240
@bind_values[argument] = value.nil? ? nil : (value ? 1 : 0)
241241
@bind_metadata[argument] = argument_metadata.merge(data_type: "NUMBER", data_precision: 1)
242242
"l_#{argument}"
243-
when "UNDEFINED"
244-
if argument_metadata[:type_name] == "XMLTYPE"
243+
when "UNDEFINED", "XMLTYPE"
244+
if argument_metadata[:type_name] == "XMLTYPE" || argument_metadata[:data_type] == "XMLTYPE"
245245
@declare_sql << "l_#{argument} XMLTYPE;\n"
246246
@assignment_sql << "l_#{argument} := XMLTYPE(:#{argument});\n" if not value.nil?
247247
@bind_values[argument] = value if not value.nil?
@@ -395,8 +395,8 @@ def add_return_variable(argument, argument_metadata, is_return_value = false)
395395
end
396396
end
397397
"l_#{argument} := " if is_return_value
398-
when "UNDEFINED"
399-
if argument_metadata[:type_name] == "XMLTYPE"
398+
when "UNDEFINED", "XMLTYPE"
399+
if argument_metadata[:type_name] == "XMLTYPE" || argument_metadata[:data_type] == "XMLTYPE"
400400
@declare_sql << "l_#{argument} XMLTYPE;\n" if is_return_value
401401
bind_variable = :"o_#{argument}"
402402
@return_vars << bind_variable

spec/plsql/procedure_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@
258258
end
259259

260260
after(:all) do
261-
plsql.execute "DROP FUNCTION test_xmltype"
262-
plsql.execute "DROP PROCEDURE test_xmltype2"
261+
plsql.execute "DROP FUNCTION test_xmltype" rescue nil
262+
plsql.execute "DROP PROCEDURE test_xmltype2" rescue nil
263263
plsql.logoff
264264
end
265265

0 commit comments

Comments
 (0)