This method executes the command using the XmlCommandType and CommandText properties and returns the result as an XML document in a .NET XmlTextReader object.


// C#
public XmlReader ExecuteXmlReader();

Return Value

An XmlReader.


The behavior of ExecuteXmlReader varies depending on the XmlCommandType property value:

  • XmlCommandType = OracleXmlCommandType.None

    ExecuteStream throws an InvalidOperationException.

  • XmlCommandType = OracleXmlCommandType.Query

    ExecuteXmlReader executes the select statement in the CommandText property, and if successful, returns a .NET XmlTextReader object containing the XML document that was generated.

    If the XML document is empty, which can happen if the SQL query does not return any rows, then an empty .NET XmlTextReader object is returned.

  • XmlCommandType = OracleXmlCommandType.Insert, OracleXmlCommandType.Update, or OracleXmlCommandType.Delete.

    The value of the CommandText property is an XML document, and ExecuteXmlReader saves the changes in that XML document to the table or view that is specified in the XmlSaveProperties property. An empty .NET XmlTextReader object is returned.