English 中文(简体)
XML 到 Oracle 数据库列映射
原标题:XML to Oracle database column mapping

我正在处理我们得到的 xml 信息。 我必须阅读 xml 并存储在 4 个不同的表格中 。

处理此事的最佳方法是什么。 让我们来说明如果 xml 模式被更改, 那么新的列可能会添加, 或者一个列可能会被删除或者重新命名等等...

如何进行这种松散的连接。 对 XML 或数据库的任何更改不需要更改代码吗?

谢谢

最佳回答

不清楚您打算如何使用曾经存储在甲骨文中的 XML, 但如果只是为审计目的存储, 您可以将 XML 存储在 CLOB 字段中, 并同时保存一个版本号和一些日期。 在另外的参考表格中, 请将 xml 版本号与其 dtd (和创建/修改的日期) 连接起来 。

问题回答

If you re using Oracle 11G you can create XMLTYPE variables in a PL/SQL procedure and You can then use the extract() function to retrieve only the parts of the XML document that you want to be fields.

After declaring a PL/SQL variable of type XMLTYPE, use the XMLTYPE.CREATEXML( ) function to create an XMLTYPE variable.

V_INPUT_XML  := XMLTYPE.CREATEXML(V_TAB.INPUT_MESSAGE);

The extract() PL/SQL function returns an XMLTYPE and I have used getclobval() to convert an XMLTYPE to a VARCHAR.

--V_OUTPUT_XML is set by a result of the extract() function 
--on an XMLTYPE
V_OUTPUT_STR := v_output_xml.getclobval();

At least with this, you only have to change your PL/SQL if the path to the fields you re setting changes; changes to the XML document outside of the fields (as long as they don t affect the XPATH to the fields) shouldn t require changes to the PL/SQL..





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签