XML IN THE DATABASE: THE XML DATA TYPE procedures or user-defined function parameters and user-defined function return codes may be XML types. This allows you to return dynamic XML to the user based on logical operations, such as in the following example. create the user-defined function CREATE FUNCTION my_business_logic( in_dept INTEGER ) RETURNS XML AS DECLARE @x XML do some business logic that produces an XML document RETURN @x GO now call it, using dept 10 SELECT * FROM dbo.my_business_logic(10) Note that the XMLreturn code is a scalar type, rather than a TABLEtype. As with XML data type columns and variables, procedure parameters and return codes can be declared with a schema collection name and used to ensure schema validity. Although being able to schema-validate input parameters may obviate the requirement for a lot of domain-checking of input, we can still use the fact that we can do processing inside procedures to make the XML a lot more dynamic. We ll see how using and producing XML based on dynamic rules and being able to pass in XML as just another data type can be used in conjunction with new extended features of the composition and decomposition functions, SELECT…FORXMLand OpenXML, in a few sections. Typed and Untyped XML Cataloging and Using XML Schema Collections In addition to storing untyped XML documents or fragments in an XML data type column, you can use SQL Server to validate your XML data type column, variable, or parameter by associating it with an XML schema collection. Therefore, you can think of XML data types as being either schema-validated (containing data types defined by a specific set of XML schemas) or untyped (containing any well-formed XML). Whether your XML type is typed or untyped, it can still contain documents or fragments, since fragments can also be schema-valid. In addition, when you define an XML type to be schema-validated, you can also specify that it can contain only XML documents, or XML documents or fragments (known as XML content).

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services

Bookmark the permalink.

Comments are closed.