Treasures of Cache 2010 Ian Cargill Development Manager Dendrite Clinical Systems.

Slides:



Advertisements
Similar presentations
Stored procedures and views You can see definitions for stored procedures and views in the demo databases but you can’t change them. For views, expand.
Advertisements

ERWin Template Overview By: Dave Wentzel. Agenda u Overview of Templates/Macros u Template editor u Available templates u Independent column browser u.
Chapter 18 - Data sources and datasets 1 Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
Advantage Data Dictionary. agenda Creating and Managing Data Dictionaries –Tables, Indexes, Fields, and Triggers –Defining Referential Integrity –Defining.
Exploring Microsoft Access 2003 Chapter 6 Many-to-Many Relationships: A More Complex System.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
PHP (2) – Functions, Arrays, Databases, and sessions.
A Guide to SQL, Seventh Edition. Objectives Create a new table from an existing table Change data using the UPDATE command Add new data using the INSERT.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Using Objects and Properties
A Guide to Oracle9i1 Advanced SQL And PL/SQL Topics Chapter 9.
A Guide to MySQL 7. 2 Objectives Understand, define, and drop views Recognize the benefits of using views Use a view to update data Grant and revoke users’
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
A Guide to SQL, Seventh Edition. Objectives Understand, create, and drop views Recognize the benefits of using views Grant and revoke user’s database.
1 Chapter 2 Reviewing Tables and Queries. 2 Chapter Objectives Identify the steps required to develop an Access application Specify the characteristics.
Information systems and databases Database information systems Read the textbook: Chapter 2: Information systems and databases FOR MORE INFO...
Access 2007 ® Use Databases How can Microsoft Access 2007 help you manage a database?
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
Microsoft Office Word 2013 Expert Microsoft Office Word 2013 Expert Courseware # 3251 Lesson 4: Working with Forms.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
ACCESS CHAPTER 1. OBJECTIVES Tables Queries Forms Reports Primary and Foreign Keys Relationship.
Copyright © 2003 by Prentice Hall Module 4 Database Management Systems 1.What is a database? Data hierarchy and data organization Field, record, file,
Copyright © 2003 by Prentice Hall Computers: Tools for an Information Age Chapter 13 Database Management Systems: Getting Data Together.
ASP.NET Programming with C# and SQL Server First Edition
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
HSCI 709 SQL Data Definition Language. SQL Standard SQL-92 was developed by the INCITS Technical Committee H2 on Databases. SQL-92 was designed to be.
Chapter 6 PHP Interacts with Mysql Database. Introduction In PHP, there is no consolidated interface. Instead, a set of library functions are provided.
UML Class Diagrams and Caché CAMTA Meeting – 1 st December 2011 John Murray Senior Product Engineer.
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
Built-in Data Structures in Python An Introduction.
INFO1408 Database Design Concepts Week 15: Introduction to Database Management Systems.
Exploring Microsoft Access Chapter 6 Many-to-Many Relationships: A More Complex System.
Caché SQL More than you think Ian Cargill Development Manager Dendrite Clinical Systems.
1/62 Introduction to and Using MS Access Database Management and Analysis Yunho Song.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Indexes / Session 2/ 1 of 36 Session 2 Module 3: Types of Indexes Module 4: Maintaining Indexes.
Oracle 11g: SQL Chapter 4 Constraints.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
1 Chapter 20 – Data sources and datasets Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
DBT544. DB2/400 Advanced Features Level Check Considerations Database Constraints File Overrides Object and Record Locks Trigger Programs.
Microsoft Access 2013 ®® Tutorial 12 Managing and Securing a Database.
A Guide to SQL, Eighth Edition Chapter Eight SQL Functions and Procedures.
MuSL Builder Handcrafting custom Mu Scenarios. MuSL in the Mu Scenario Editor.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Task #1 Create a relational database on computers in computer classroom 308, using MySQL server and any client. Create the same database, using MS Access.
Chapter 8 Manipulating MySQL Databases with PHP PHP Programming with MySQL 2 nd Edition.
Chapter 12 Additional Database Objects. Chapter Objectives  Define the purpose of a sequence and state how it can be used by an organization  Explain.
Learningcomputer.com SQL Server 2008 –Views, Functions and Stored Procedures.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
InterSystems’ New Dynamic SQL Features Louise Parberry – Senior Sales Engineer.
IS6146 Databases for Management Information Systems Lecture 3: SQL III – The DDL Rob Gleasure robgleasure.com.
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
Stored Procedures / Session 4/ 1 of 41 Session 4 Module 7: Introducing stored procedures Module 8: More about stored procedures.
Module 6: Administering Reporting Services. Overview Server Administration Performance and Reliability Monitoring Database Administration Security Administration.
ObjectScript Highlights Ian Cargill Development Manager Dendrite Clinical Systems.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
In this session, you will learn to: Create and manage views Implement a full-text search Implement batches Objectives.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Introduction to Database Programming with Python Gary Stewart
Objectives Query for top values Create a parameter query
A Guide to SQL, Eighth Edition
IST 318 Database Administration
Presentation transcript:

Treasures of Cache 2010 Ian Cargill Development Manager Dendrite Clinical Systems

Before We Start Terminal Window Tricks ! To run an OS Shell command D $System.SQL.Shell() q(uit) to exit back to terminal

New Dynamic SQL (New in Caché 2010) This is based on the new %SQL.Statement and %SQL.StatementResult (and related) classes. %SQL.Statement - implements an interface to prepare and execute dynamic SQL statements. %SQL.StatementResult - Every dynamic statement execution returns a result object.

New Dynamic SQL Chapter in online Documents: "Using Dynamic SQL" Superficially similar to %ResultSet (%Prepare, %Execute, etc), but many additional features and advantages.

Can set DisplayMode as argument to %New More flexible Prepare of query (e.g. can pass multiline query as array!) %ExecDirect combines %Prepare and %Execute %Display method (for debug) %Print (with optional delimiter) - e.g. to produce CSV files but as Louise is doing an entire session on this - that is all I will say …

%SYSTEM.Encryption This class provides class functions to perform data encryption, Base64 encoding, hashing, and generation of message authentication codes. Some complex encryption support for experts, but a number of useful applications for the more humble programmer:

%SYSTEM.Encryption Encrypting passwords for storage –e.g. MD5Hash, SHA1Hash Encoding binary data for 'plain text' transmission. E.g. SOAP messages. –Base64Encode –Base64Decode

ClassMethod Base64ToFile(ByRef Data64 As %String, FileName As %Library.String) As %Library.String { Set res="OK" try { Set dat=##class(%SYSTEM.Encryption).Base64Decode(Data64) Set file=##class(%File).%New(FileName) Do file.Open("WN") Do file.Write(dat) Do file.Close() Kill file } catch { Set res=$ZError } Quit "OK“ }

GUIDs If a persistent class is marked as GUIDENABLED, Caché will assign Globally Unique IDentifiers (GUIDs) to each object when it is created. A later call to delete the object via %Delete on an object will no longer delete the GUID for that object. There is history in the GUID global in each namespace where a GUIDENABLED object has been created. Users are responsible for removing entries from ^OBJ.GUID that are no longer needed.

GUIDs Primarily for Synchronization. But can be other uses. ^OBJ.GUID(0, "B43096CB-D24E-4A79-9A3D-D998E56C6B78")=$lb("4","Guid.Test") "B810DCE6-5BE9-4CC7-8E37-38A281BA2B67")=$lb("5","Guid.Test") "FE3D D6-4E84-AD46-6E027506A6F9")=$lb("6","Guid.Test") ^OBJ.GUID(1, $lb("4","Guid.Test"))="B43096CB-D24E-4A79-9A3D-D998E56C6B78" $lb("5","Guid.Test"))="B810DCE6-5BE9-4CC7-8E37-38A281BA2B67" $lb("6","Guid.Test"))="FE3D D6-4E84-AD46-6E027506A6F9"

Class Guid.Test Extends %Persistent { Parameter GUIDENABLED = 1; Property Name As %Library.String [ SqlColumnNumber = 2 ]; Property GUID As %Library.String [ Calculated, SqlComputeCode = { SET {GUID}=##class(Guid.Test).GetGUID({ID})}, SqlComputed, SqlColumnNumber =3 ]; Method GUIDGet() As %Library.String { Set key=..GetGUID(..%Id()) } ClassMethod GetGUID(Id As %Library.String) As %Library.String { Set key=$lb(Id,"Guid.Test") Quit ^OBJ.GUID(1,key) } }

GUID Add three rows and SELECT * FROM Guid.Test gives: #IDNameGUID , A0429A7-C DB2-CCF11AB6BCB , C-D C-AD33-A90E31D , FB-AEF1-DBE6A6FD0662

Referential Integrity on ID field Post Meeting Update: After the meeting, I raised this with InterSystems, and it seems there IS a way to do it, but no-one knew!! You can’t use the Wizard, but write the FK by hand, and simply OMIT THE INDEX NAME from the final argument. I.e. ForeignKey FKey(FieldName) References Sample.Parent()

Referential Integrity on ID field Some parts of ObjectScript are definitely brain-damaged. One such is how you define Referential Integrity. Typical Database: e.g. SQL Server ADD CONSTRAINT FK_XX FOREIGN KEY (ORDERNUMBER) REFERENCES DBO.ORDERHEADER(ORDERNUMBER) >>TABLE(FIELD)

Referential Integrity You define RI in a child class as, say… ForeignKey FKey(FieldName) References Sample.Parent(IName) Where Iname is the name of an index in IndexName in the parent class. Question? What is the name of the index on the default ID field??

Referential Integrity Because ID doesn't have an explicit index, you CANNOT directly reference the Primary Key field of the parent!!! Only in Cach é !! There is, however, a workaround, based on the fact that you can index calculated fields. Try this …

Class Reference.Parent Extends %Persistent { Index IPKId On PKId [unique]; Property PKId As %Library.Integer [ Calculated, SqlColumnNumber = 2, SqlComputeCode = { SET {PKId}={id}}, SqlComputed ]; Method PKIdGet() As %Library.Integer [ CodeMode = expression ] {..%Id() } Property ThisProperty As %Library.String; Property ThatProperty As %Library.Integer; }

Class Reference.Child Extends %Persistent { Property MyParentId As %Library.Integer; ForeignKey FkParent(MyParentId) References Reference.Parent(IPKId); Property ThisProperty As %Library.String; Property ThatProperty As %Library.Integer; }

$ZOBJ Functions Replaced The $ZOBJ functions have been replaced with standard Cach é functions. The $ZOBJ functions are still available to applications, but they are no longer documented. The calling sequences for the replacement functions remain the same as before; a textual substitution is all that is required to update the application usage. The replacements are given in the following table:

Was Now use $ZOBJCLASSMETHOD$CLASSMETHOD $ZOBJMETHOD$METHOD $ZOBJPROPERTY$PROPERTY $ZOBJCLASS$CLASSNAME Note: The function, $ZOBJCLASS, was not documented in prior versions. $ZOBJ Functions Replaced

Old style Set oDat=$ZObjClassMethod(Class, "%New") Set oDat=$ZObjClassMethod(Class, "%OpenId", ObjId) Set CurrentVal=$ZOBJPROPERTY(oDat, FldName) Set $ZOBJPROPERTY(oDat, FldName)=NewValue

New Style Set oDat=$CLASSMETHOD(Class, "%New") Set oDat=$CLASSMETHOD(Class, "%OpenId", ObjId) Set CurrentVal=$PROPERTY(oDat, FldName) Set $PROPERTY(oDat, FldName)=NewValue

Private Classmethods Now Supported Cach é now supports private class methods. Private classmethods cannot be called from outside of the class (or a subclass). For backward compatibility, all class methods have been marked “ public ” so customer code will continue to work correctly. The descriptions of these methods have been altered to add the string, “ [Previously private] ”, to them. New private classmethods added to classes in the future will be inaccessible from outside the class.