CF and Stored Procedures Lei Wang ALP International.

Slides:



Advertisements
Similar presentations
What is a Transaction? A transaction is a logical logic of work A transaction may have one of two outcomes –When a transaction completes successfully,
Advertisements

Chapter 4B: More Advanced PL/SQL Programming
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
A Guide to Oracle9i1 Advanced SQL And PL/SQL Topics Chapter 9.
Fundamentals, Design, and Implementation, 9/e Chapter 7 Using SQL in Applications.
A Guide to SQL, Seventh Edition. Objectives Embed SQL commands in PL/SQL programs Retrieve single rows using embedded SQL Update a table using embedded.
Database Administration Part 1 Chapter Six CSCI260 Database Applications.
Transaction Management and Concurrency Control
Introduction to PL/SQL Lecture 0 – Self Study Akhtar Ali.
1 © ALP International CorporationMarch 2001 MD-CFUG Automating your Website Testing By Andrew L. Pollner and Lei Wang ALP International Corporation.
Module 2: Using Transact-SQL Querying Tools. Overview SQL Query Analyzer Using the Object Browser Tool in SQL Query Analyzer Using Templates in SQL Query.
Module 15: Monitoring. Overview Formulate requirements and identify resources to monitor in a database environment Types of monitoring that can be carried.
PL/SQL and the Table API. Benefits of Server-Side Code Speedy Pizza MENU NAPOLITAINE PIZZA Reduced network traffic Maintainability Data integrity Triggers.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 13 Managing Databases with SQL Server 2000.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 David M. Kroenke’s Chapter Seven: SQL for Database Construction and.
Exceptions Oracle Database PL/SQL 10g Programming Chapter 7.
Benefits of PL/SQL. 2 home back first prev next last What Will I Learn? In this lesson, you will learn to: –List and explain the benefits of PL/SQL –List.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
1 Overview of Databases. 2 Content Databases Example: Access Structure Query language (SQL)
Sofia, Bulgaria | 9-10 October SQL Server 2005 High Availability for developers Vladimir Tchalkov Crossroad Ltd. Vladimir Tchalkov Crossroad Ltd.
COLD FUSION Deepak Sethi. What is it…. Cold fusion is a complete web application server mainly used for developing e-business applications. It allows.
Stored Procedures, Transactions, and Error-Handling
I Copyright © 2004, Oracle. All rights reserved. Introduction Copyright © 2004, Oracle. All rights reserved.
Stored Procedures, Triggers, Program Access Dr Lisa Ball 2008.
SQL Server 7.0 Maintaining Referential Integrity.
CSE 3330 Database Concepts Stored Procedures. How to create a user CREATE USER.. GRANT PRIVILEGE.
1 Copyright © 2004, Oracle. All rights reserved. Introduction to PL/SQL.
BA372 Stored Procedures and Triggers Lab. What needs to be done to change a customer’s credit limit? Who am I? May I? Do it Log it Display A database.
PRACTICE OVERVIEW PL/SQL Part Examine this package specification and body: Which statement about the V_TOTAL_BUDGET variable is true? A. It must.
1 Copyright © 2004, Oracle. All rights reserved. Introduction to PL/SQL.
CIS4368: Advanced DatabaseSlide # 1 PL/SQL Dr. Peeter KirsSpring, 2003 PL/SQL.
8 1 Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 8 Advanced SQL.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Management COP4540, SCS, FIU Oracle PL/SQL (Ch 10.5)
Commercial RDBMSs Access and Oracle. Access DBMS Architchecture  Can be used as a standalone system on a single PC: -JET Engine -Microsoft Data Engine.
CMPE 226 Database Systems October 7 Class Meeting Department of Computer Engineering San Jose State University Fall 2015 Instructor: Ron Mak
What is a Package? A package is an Oracle object, which holds other objects within it. Objects commonly held within a package are procedures, functions,
Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
A Guide to SQL, Eighth Edition Chapter Eight SQL Functions and Procedures.
Database Security Cmpe 226 Fall 2015 By Akanksha Jain Jerry Mengyuan Zheng.
ViaSQL Technical Overview. Viaserv, Inc. 2 ViaSQL Support for S/390 n Originally a VSE product n OS/390 version released in 1999 n Identical features.
CodePainter Revolution Trainer Course Max Vizzini RunTime Framework.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
IT420: Database Management and Organization Triggers and Stored Procedures 24 February 2006 Adina Crăiniceanu
Module 14: Managing Transactions and Locks. Overview Introducing Transactions and Locks Managing Transactions Understanding SQL Server Locking Architecture.
1 Stored Procedure, Function and Trigger. 2Objectives 1. Database Programming 2. Stored Procedure 3. Function 4. Trigger.
Query Optimization By Rick Mason, SeedChoices.com.
7.5 Using Stored-Procedure and Triggers NAME MATRIC NUM GROUP Muhammad Azwan Bin Khairul Anwar CS2305A Muhammad Faiz Bin Badrol Shah CS2305B.
COMP 430 Intro. to Database Systems Transactions, concurrency, & ACID.
COMP 430 Intro. to Database Systems
A Guide to SQL, Seventh Edition
Stored Procedures.
Web Technologies IT230 Dr Mohamed Habib.
11 | Error Handling and Transactions
Introduction to Triggers
The Client/Server Database Environment
T-SQL Transact - Structured Query Language (Microsoft)
PL/SQL Scripting in Oracle:
Stored Procedure, Function and Trigger
PL/SQL week10.
Chapter 7 Using SQL in Applications
Chapter 7 Using SQL in Applications
Chapter 8 Advanced SQL.
MATERI PL/SQL Procedures Functions Packages Database Triggers
Chapter 11 Managing Databases with SQL Server 2000
COP 2700 – Data Structures (SQL)
Updating Databases With Open SQL
Updating Databases With Open SQL
Presentation transcript:

CF and Stored Procedures Lei Wang ALP International

Main Topics Database Locks How Cold Fusion perform DB locks Stored Procedure Stress test to compare Cftransaction and stored procedure How to use stored procedure Common Mistakes

Database Locks “Lost update problem” Multiple users accessing the same data Read from database Update record User1 User2

Database Locks Blocking access for all other users User1 User2 Begin Transaction Commit Transaction Begin Transaction Commit Transaction Lock Read Value Update Value Lock Read Value Update Value Waiting

Types of Locks Table-level: supported by all database. The entire table is locked when a user is posting a transaction that utilizes a row from that table Row-level:supported by higher-end database. Only records being utilized by a transaction are locked.

How Cold Fusion perform DB Locks Use CFTRANSACTION to group multiple queries into a single unit. CFTRANSACTION also provides commit and rollback processing. ACTION="BEGIN" or "COMMIT" or "ROLLBACK" ISOLATION="Read_Uncommitted" or "Read_Committed" or "Repeatable_Read" CFLOCK

Standard usage of cftransaction(from CF Studio) INSERT INTO Courses (Number, Descript) VALUES ('#myNumber#', '#myDescription#') ……………………………………… Ending tag within the cftry block should be a cfcatch tag

Standard usage of cftransaction INSERT INTO Courses (Number, Descript) VALUES ('#myNumber#', '#myDescription#') ………………………………………

How DB tools perform Lock Transaction A logical unit of work. Begin the transaction Commit the transaction or rollback transaction

Standard usage of transaction BEGIN TRANSACTION MyTransaction SELECT * FROM roysched WHERE title_id LIKE ‘Pc%’ UPDATE roysched SET royalty = royalty * 1.10 WHERE title_id LIKE 'Pc%' COMMIT TRANSACTION MyTransaction

Stored Procedure A stored procedure is basically a precompiled program that is stored at the server site. Stored procedure is not written in SQL PL/SQL Oracle Transact-SQL Sybase & SQL Server

Advantage of Stored Procedure It enables you to write and maintain a single set of code that is utilized by all current and future applications that utilize the database It insulates the application developers from the structure of the database It can provide better performance.

Stress test LoadRunner is used to conduct 3 levels of stress test, 10, 50, 100 users. Internal network 100 M bps Cold Fusion server 5 on Windows 2000 server (1.5 Ghz CPU, 512 MB memory) SQL server 7 on the same Windows 2000 server 5 Pentium 430 Mhz Dell machines as client

Stress test results Userscftransaction Stored Procedure

What determines which tool to use Less traffic, simple web page CFTRSACTION Heavy traffic, complicated web pages Stored procedure

How to write stored procedure CREATE PROCEDURE int output AS BEGIN TRANSACTION from T_Invoice Insert into T_Invoice values( IF <>0 ROLLBACK TRANSACTION ELSE COMMIT TRANSACTION

How to use stored procedure Cfstoredproc tag <CFSTOREDPROC PROCEDURE ="procedure name" DATASOURCE ="ds_name" USERNAME="username" PASSWORD="password" DBSERVER="dbms" DBNAME="database name" BLOCKFACTOR="blocksize" PROVIDER="COMProvider" PROVIDERDSN="datasource" DEBUG="Yes/No" RETURNCODE="Yes/No">

How to user Stored Procedure Cfprocparam tag <CFPROCPARAM TYPE="IN/OUT/INOUT" VARIABLE="variable name" DBVARNAME="DB variable name" VALUE="parameter value“ CFSQLTYPE="parameter datatype“ MAXLENGTH="length" SCALE="decimal places" NULL="yes/no">

CFPROCPARAM Type: IN/OUT/INOUT CFSQLTYPE 17 total CF_SQL_INTEGER CF_SQL_CHAR CF_SQL_VARCHAR CF_SQL_DATE CF_SQL_MONEY

CFPROCPARAM DBVARNAME VARIABLE CF variable name

How to use Stored Procedure

Common mistakes when using Stored Procedure Declaration order in stored procedure is different from CFPROCPARAM order Error message Operand type clash: int is incompatible with text

Variables are not in the same int output

Common Mistakes Every In variable need a value create procedure varchar(60) as Begin FROMT_Student UPDATET_Invoice END

Every Variable need a value

Conflict with other DB tools CFTRANSACTION and TRIGGER Triggers are specialized stored procedures that are executed automatically when a particular event occurs and are used to enforce data integrity A lot of triggers have Rollback transaction command

Trigger CREATE TRIGGER Insert_T_ContactsON T_Contacts FOR int, FROMINSERTED FROMT_Contacts IF > 0 ROLLBACK TRANSACTION End

Q & A