5/24/01 Leveraging SQL Server 2000 in ColdFusion Applications December 9, 2003 Chris Lomvardias SRA International

Slides:



Advertisements
Similar presentations
Yukon – What is New Rajesh Gala. Yukon – What is new.NET Framework Programming Data Types Exception Handling Batches Databases Database Engine Administration.
Advertisements

2/23/05 CS Advanced Databases 1 XML Support in SQL Server 2000 Sriram Krishnan Kevin Menard.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Structure Query Language (SQL) COMSATS INSTITUTE OF INFORMATION TECHNOLOGY, VEHARI.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Inside Data Access with SQLXML: Architecture Guide Rolandas Gricius MCT, MCSE, MCSD Adapted From.
Fundamentals, Design, and Implementation, 9/e Chapter 6 Introduction to Structured Query Language (SQL)
Database Systems More SQL Database Design -- More SQL1.
Module 9 Designing an XML Strategy. Module 9: Designing an XML Strategy Designing XML Storage Designing a Data Conversion Strategy Designing an XML Query.
SQL Server 2000 and XML Erik Veerman Consultant Intellinet Business Intelligence.
DAT304 Leveraging XML and HTTP with Sql Server Irwin Dolobowsky Program Manager Webdata Group.
2.2 SQL Server 2005 的 XML 支援功能. Overview XML Enhancements in SQL Server 2005 The xml Data Type Using XQuery.
Topics Views Stored Procedures User Defined Functions Triggers.
SQL Basics. SQL SQL (Structured Query Language) is a special-purpose programming language designed from managing data in relational database management.
Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 1 of 31 Objectives In this lesson, you will learn to: * Generate.
Rationale Aspiring Database Developers should be able to efficiently query and maintain databases. This module will help students learn the Structured.
Introduction to Databases Chapter 8: Improving Data Access.
Database Design for DNN Developers Sebastian Leupold.
Introduction to Databases Chapter 6: Understanding the SQL Language.
Functions Lesson 10. Skills Matrix Function A function is a piece of code or routine that accepts parameters and stored as an object in SQL Server. The.
XML in SQL Server Overview XML is a key part of any modern data environment It can be used to transmit data in a platform, application neutral form.
CSE314 Database Systems More SQL: Complex Queries, Triggers, Views, and Schema Modification Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
SQL/Lesson 4/Slide 1 of 45 Using Subqueries and Managing Databases Objectives In this lesson, you will learn to: *Use subqueries * Use subqueries with.
By: Matt Batalon, MCITP  Another form of temporary storage that can be queried or joined against, much like a table variable, temp.
Nitin Singh/AAO RTI ALLAHABAD 1 SQL Nitin Singh/AAO RTI ALLAHABAD 2 OBJECTIVES §What is SQL? §Types of SQL commands and their function §Query §Index.
Module 18 Querying XML Data in SQL Server® 2008 R2.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Retrieving XML Data from SQL server.  Using the FOR XML Clause to Retrieve Data Retrieving Data in XML Format How SQL Server Generates XML Using the.
SQL Server 2005 Implementation and Maintenance Chapter 3: Tables and Views.
Visual Programing SQL Overview Section 1.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
Slide 1 of 19Session 13 Ver. 1.0 Querying and Managing Data Using SQL Server 2005 In this session, you will learn to: Implement stored procedures Implement.
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
Chapter 14 1 Chapter 14 Storing and Retrieving XML in SQL Server 2000 November 6, 2001 Sook-Kyo Kwon.
Session 1 Module 1: Introduction to Data Integrity
Learningcomputer.com SQL Server 2008 –Views, Functions and Stored Procedures.
SQLXML XML Technology For SQL Server Brian Moore Developer and Platform Strategy Group Microsoft Corporation.
Slide 1 Chapter 7 – Part 3 Stored Procedure, Function &Trigger.
SQL Server 2012 Session: 1 Session: 12 Triggers Data Management Using Microsoft SQL Server.
Module 3: Using XML. Overview Retrieving XML by Using FOR XML Shredding XML by Using OPENXML Introducing XQuery Using the xml Data Type.
DAT 405 Extreme SqlXml Irwin Dolobowsky Program Manager – SqlXml Microsoft Corporation.
Stored Procedures / Session 4/ 1 of 41 Session 4 Module 7: Introducing stored procedures Module 8: More about stored procedures.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
DML Statements contd.. SQL Server CURSORS Cursor is used in handling results of select query for data calculations Cursors are used as buffered.
Last Updated : 27 th April 2004 Center of Excellence Data Warehousing Group Teradata RDBMS Concepts.
Aggregator Stage : Definition : Aggregator classifies data rows from a single input link into groups and calculates totals or other aggregate functions.
SQL Triggers, Functions & Stored Procedures Programming Operations.
Create Stored Procedures and Functions Database Management Fundamentals LESSON 2.4.
Delete Data Database Administration Fundamentals LESSON 3.4.
Module 9: Implementing Functions. Overview Creating and Using Functions Working with Functions Controlling Execution Context.
Implementing Functions Advanced Database Dr. AlaaEddin Almabhouh.
Views / Session 3/ 1 of 40 Session 3 Module 5: Implementing Views Module 6: Managing Views.
DAT 400 Inside Data Access with SQLXML: Architecture Guide Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
Big Data Yuan Xue CS 292 Special topics on.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
MySQL Subquery Source: Dev.MySql.com
Using XML in SQL Server and Azure SQL Database
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
Dirt, Spit, and Happy FLWOR
JDBC.
Overview Implementing Triggers Implementing XML Schemas.
Database systems Lecture 3 – SQL + CRUD
Data Model.
C1. SQL BAsic.
Contents Preface I Introduction Lesson Objectives I-2
Chapter 8 Advanced SQL.
Improving the Performance of Functions
Presentation transcript:

5/24/01 Leveraging SQL Server 2000 in ColdFusion Applications December 9, 2003 Chris Lomvardias SRA International

5/24/01 Presentation Agenda User-Defined Functions XML Support Code Examples Resources

5/24/01 Functions Built-In Functions in SQL Server 2000 –Built-in subroutines that encapsulate frequently performed logic –Cannot be modified Rowset Functions –Return object that can be used as table reference –OpenXML (to be discussed later) Aggregate Functions –Take a collection of values and return a single value –Max(), Min(), Avg(), Sum(), Count() Scalar Functions –Take a single value and return a single value –Configuration functions –Cursor functions –Date and Time functions (getdate) –Mathematical functions (round) –Metadata functions –Security functions –String functions (substring, upper) –System functions case, isnull,nullif) –System statistical functions –Text and image functions

5/24/01 User-Defined Functions New in SQL Server 2000 –User-defined functions introduced in SQL Server 2000, enabling programmers to create custom functions (user-defined functions introduced in ColdFusion 5!) Advantages –Code simplification –Readability –Code reuse –Maintainability Three Types of User-DefinedFunctions –scalar –inline table-valued –multistatement table-valued Syntax –CREATE FUNCTION –ALTER FUNCTION –DROP FUNCTION

5/24/01 UDF Types Scalar –Operate on a single value and then return a single value Inline Table-Valued –Return clause specifies TABLE (e.g., parameterized view) Multistatement Table-Valued –Return clause specifies a TABLE type with columns and their data types CREATE FUNCTION fn_AuthorsInState varchar(5) RETURNS TABLE AS RETURN (SELECT au_lname from authors where CREATE FUNCTION fn_AllAuthors () TABLE ( au_id int, au_lname varchar(40), au_fname varchar(20)) AS BEGIN SELECT au_id, au_lname, au_fname FROM authors RETURN END

5/24/01 UDF Limitations Using built-in functions in UDFs –Cannot use nondeterministic functions inside a UDF (e.g., getdate() cannot be used, though there are some workarounds) Performance considerations –In some situations UDFs can be slower than using TSQL; if you can do it using TSQL, you are probably better off not writing a UDF System (Global) UDFs –Not recommended but appear to work; make sure you research implications before implementing

5/24/01 FOR XML FOR XML mode [, XMLDATA] [, ELEMENTS][, BINARY BASE64] XML mode –Specifies the XML mode. XML mode determines the shape of the resulting XML. Mode can be RAW, AUTO, or EXPLICIT. XMLDATA –Specifies that an XML-Data schema should be returned. The schema is prepended to the document as an inline schema. ELEMENTS –If the ELEMENTS option is specified, the columns are returned as sub-elements. Otherwise, they are mapped to XML attributes. This option is supported in AUTO mode only. BINARY BASE64 –If the BINARY Base64 option is specified, any binary data returned by the query is represented in base64-encoded format.

5/24/01 FOR XML Mode Raw –Returns an element for each row in the query Auto –Returns rows as nested elements based on table(s) Explicit –Provides granular control of shape of generated XML ColdFusion Column = XML_F52E2B61-18A1-11d1-B F49916B SELECT au_id, au_lname, au_fname FROM authors FOR XML AUTO #htmleditformat(xmlString)#

5/24/01 FOR XML Limitations Limitations –Can’t use in a View –Can’t use with Cursors –Doesn’t support Compute By –Can’t use in a subselect, nested Select or Select Into –Can’t use in a User Defined Function Other Considerations –Doesn’t generate well-formed XML (just fragments) –NULLS do not appear –Watch out for low-order, non-printable ASCII characters (CDATA is an option)

5/24/01 FOR XML EXPLICIT FOR XML EXPLICIT – Universal Table ElementName!TagNumber!AttributeName!Directive Directives –xml –hide –cdata –xmltext –element SELECT 1 as Tag, null as Parent, au_fname as [Author!1!FirstName!Hide], au_lname as [Author!1!LastName!Element], au_id as [Author!1!ID] FROM authors FOR XML EXPLICIT

5/24/01 OPENXML OpenXML provides a relational view of XML data –SELECT –INSERT –UPDATE –DELETE Advantages –Reduce database calls –Act on multiple tables in one step –Act on multiple rows in one step –Join with existing tables –Store open content Disadvantages –Performance issues with large documents

5/24/01 OPENXML Usage in stored procedures –Declare handle –Declare incoming packet –Obtain document handle –Execute statement against packet (Xpath) –Release from memory OPENXML(iDoc, rowpattern, flags) [WITH (rowsetschema [colpatterns] | tablename)] 0 Default value. Attribute centric mapping 1 Use Attribute centric mapping 2 Use element centric mapping 8 Only unconsumed data should be copied to the overflow

5/24/01 Additional Options IIS Virtual Directory (template, URL queries) Updategrams XML Bulk Load SQLXML Managed Classes -.Net Web Services Support

5/24/01 Resources