dcDB Stored Procedures: An Overview

Slides:



Advertisements
Similar presentations
HTML Forms. collect information for passing to server- side processes built up from standard widgets –text-input, radio buttons, check boxes, option lists,
Advertisements

RPC Robert Grimm New York University Remote Procedure Calls.
The Web Warrior Guide to Web Design Technologies
1 Chapter 12 Working With Access 2000 on the Internet.
PHP (2) – Functions, Arrays, Databases, and sessions.
CSCI 4550/8556 Computer Networks Comer, Chapter 3: Network Programming and Applications.
Inter Process Communication:  It is an essential aspect of process management. By allowing processes to communicate with each other: 1.We can synchronize.
DT228/3 Web Development Databases. Database Almost all web application on the net access a database e.g. shopping sites, message boards, search engines.
Guide To UNIX Using Linux Third Edition
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Dataface API Essentials Steve Hannah Web Lite Solutions Corp.
JavaScript Form Validation
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
INTERNET APPLICATION DEVELOPMENT For More visit:
JavaScript & jQuery the missing manual Chapter 11
TCP/IP protocols Communication over Internet is mostly TCP/IP (Transmission Control Protocol over Internet Protocol) TCP/IP "stack" is software which allows.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
4-1 INTERNET DATABASE CONNECTOR Colorado Technical University IT420 Tim Peterson.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Tutorial 10 Adding Spry Elements and Database Functionality Dreamweaver CS3 Tutorial 101.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
ADO.NET A2 Teacher Up skilling LECTURE 3. What’s to come today? ADO.NET What is ADO.NET? ADO.NET Objects SqlConnection SqlCommand SqlDataReader DataSet.
Copyright © 2007, Oracle. All rights reserved. Managing Concurrent Requests.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Bonrix SMPP Client. Index Introduction Software and Hardware Requirements Architecture Set Up Installation HTTP API Features Screen-shots.
Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#:
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.
(Chapter 10 continued) Our examples feature MySQL as the database engine. It's open source and free. It's fully featured. And it's platform independent.
PHP1-1 PHP Lecture 2 Xingquan (Hill) Zhu
Website Development with PHP and MySQL Saving Data.
Chapter 6 Server-side Programming: Java Servlets
CSC 2720 Building Web Applications Server-side Scripting with PHP.
XHTML & Forms. PHP and the WWW PHP and HTML forms – Forms are the main way users can interact with your PHP scrip Typical usage of the form tag in HTML.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
CS 4720 Dynamic Web Applications CS 4720 – Web & Mobile Systems.
Google App Engine Data Store ae-10-datastore
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Implementing The Middle Tier These slides.
1 Java Servlets l Servlets : programs that run within the context of a server, analogous to applets that run within the context of a browser. l Used to.
Gold – Crystal Reports Introductory Course Cortex User Group Meeting New Orleans – 2011.
Introduction to Servlets Allen Day. Notes This is a training NOT a presentation Please ask questions Prerequisites.
How to write a MSGQ Transport (MQT) Overview Nov 29, 2005 Todd Mullanix.
AMQP, Message Broker Babu Ram Dawadi. overview Why MOM architecture? Messaging broker like RabbitMQ in brief RabbitMQ AMQP – What is it ?
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
RESTful Web Services What is RESTful?
ICM – API Server Gary Ratcliffe. 2 Agenda Webinar Programme API Server Overview JSON-RPC iCM API Service API Server and Forms New services under.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Web Services An Introduction Copyright © Curt Hill.
Since you’ll need a place for the user to enter a search query. Every form must have these basic components: – The submission type defined with the method.
DICOMwebTM 2015 Conference & Hands-on Workshop University of Pennsylvania, Philadelphia, PA September 10-11, 2015 DICOMweb Workflow API (UPS-RS) Jonathan.
2 Copyright © 2004, Oracle. All rights reserved. Running a Forms Developer Application.
2 Copyright © 2006, Oracle. All rights reserved. Running a Forms Developer Application.
1 Network Communications A Brief Introduction. 2 Network Communications.
ISC321 Database Systems I Chapter 2: Overview of Database Languages and Architectures Fall 2015 Dr. Abdullah Almutairi.
Java Autonomous Artificial Intelligence By : Abhishek Singh
Emdeon Office Batch Management Services This document provides detailed information on Batch Import Services and other Batch features.
Core LIMS Training: Project Management
Y.-H. Chen International College Ming-Chuan University Fall, 2004
Running a Forms Developer Application
Featured Enhancements to the IDE & Debugger
Data Virtualization Tutorial: Introduction to SQL Script
z/Ware 2.0 Technical Overview
Java Course Review.
Out-of-Process Components
PHP / MySQL Introduction
WEB API.
Relational Database Design
Out-of-Process Components
Presentation transcript:

dcDB Stored Procedures: An Overview DivConq Framework’s MUMPS API dcDB Stored Procedures: An Overview

Connectivity Linux, Windows or OS X Box Linux Box Java App w/ DivConq MUMPS SSH Java code connects to the MUMPS database via an SSH connection. This keeps the data secure while in transit.

Local Connectivity Linux Box Java App SSH MUMPS w/ DivConq Of course there is no reason why Java cannot run on the same box. SSH is still used, connecting over the loopback network interface.

Channels Linux, Windows or OS X Box Linux Box Java App w/ DivConq MUMPS Session Channels One SSH session is used. Multiple SSH channels enable greater throughput. Typically DivConq uses three channels, which creates three MUMPS processes.

Request-Response Linux, Windows or OS X Box Linux Box Java App w/ DivConq MUMPS Communication is Request-Response only, requests are originated in Java and responses are supplied by MUMPS code. By using three channels, up to three requests can be processed at once. A long running request does not hold up other requests.

Request Structure Structure Name: [Stored Procedure Name] Kind: “Update” or “Query” Params: [any JSON-like data structure] Example Name: “dctListPeople” Kind: “Query” Params: { “MinAge”: 30, “MaxAge”: 48 } Your code builds a request and submits it to DivConq’s database interface. A request must have a name and a kind, parameters are optional. Name = name of the stored procedure. Kind will be Update only if it changes data within the database (Insert, Update, Delete), otherwise use Query.

Request Flow, Step 1 Java App w/ DivConq MUMPS DivConq Database Interface MUMPS Process Request Queue Your Application Code Request Verifier MUMPS Process Database Workers #1 Response Verifier MUMPS Process DivConq Schema #1 - Your code builds a request and submits it. Request submission is asynchronous, so you also must provide a callback to handle the result.

Request Flow, Step 2 Java App w/ DivConq MUMPS DivConq Database Interface MUMPS Process Request Queue Your Application Code Request Verifier MUMPS Process Database Workers #1 Response Verifier MUMPS Process #2 DivConq Schema #2 – Your request is verified, including validating the parameters with what is declared in the schema.

Request Flow, Step 3 Java App w/ DivConq MUMPS DivConq Database Interface MUMPS Process Request Queue #3 Your Application Code Request Verifier MUMPS Process Database Workers #1 Response Verifier MUMPS Process #2 DivConq Schema #3 – If verification passes your request is put on to the request queue.

Request Flow, Step 4 Java App w/ DivConq MUMPS DivConq Database Interface MUMPS Process Request Queue #3 #4 Your Application Code Request Verifier MUMPS Process Database Workers #1 Response Verifier #4 MUMPS Process #2 DivConq Schema #4 – When a database worker (channel) is available, it takes the request from the queue and sends it to MUMPS.

Response Flow, Step 5 Java App w/ DivConq MUMPS DivConq Database Interface MUMPS Process Request Queue #3 #4 Your Application Code Request Verifier MUMPS Process Database Workers #1 Response Verifier #4 and #5 MUMPS Process #2 DivConq Schema #5 – That worker then reads (blocking) the result and any accompanying debug/error messages.

Response Flow, Step 6 Java App w/ DivConq MUMPS DivConq Database Interface MUMPS Process Request Queue #3 #4 Your Application Code Request Verifier MUMPS Process Database Workers #1 Response Verifier #4 and #5 MUMPS Process #2 #6 DivConq Schema #6 – The response is verified by validating the (JSON-like) result with what is declared in the schema. If response does not validate, error messages are added to messages collected from MUMPS.

Response Flow, Step 7 Java App w/ DivConq MUMPS DivConq Database Interface MUMPS Process Request Queue #3 #4 Your Application Code Request Verifier MUMPS Process Database Workers #1 Response Verifier #4 and #5 MUMPS Process #7 #2 #6 DivConq Schema #7 – The response and any debug/error messages are delivered to your code via a the callback you provided at submission.

Request in Java, Step 1 Example RecordStruct ages = new RecordStruct(); ages.setField("MinAge", 3); ages.setField("MaxAge", 8); Parameters are composed of JSON-like structures. In DivConq use RecordStruct to compose records (aka Objects in JSON) and ListStruct to compose lists (aka Arrays in JSON). Records (aka Objects) have fields – just as in JSON – the field values may be lists, records or scalars. Above we are using numeric scalars.

Request in Java, Step 2 Example RecordStruct ages = new RecordStruct(); ages.setField("MinAge", 3); ages.setField("MaxAge", 8);   QueryRequest request = new QueryRequest("dctListPeople", ages); Create the request object. The Name and Kind are required. Kind can be derived from the class name (QueryRequest vs UpdateRequest). Name is the first parameter to the constructor. The parameters, optionally, follow the name in the call to the constructor.

Request in Java, Step 3 ObjectCallback callback = new ObjectCallback() { @Override public void process(ObjectResult result) { System.out.println("Messages:"); TestDb.printPretty(result.getMessages()); System.out.println(); System.out.println("Result:"); TestDb.printPretty(result.getResult()); } }; You also need to create a callback object. This example callback simply prints the messages and results to the console as JSON output. You may call “getResultAsRec” (RecordStruct) or “getResultAsList” (ListStruct) to process the result using DivConq’s JSON-like API.

Request in Java, Step 4 Example RecordStruct ages = new RecordStruct(); ages.setField("MinAge", 3); ages.setField("MaxAge", 8);   QueryRequest request = new QueryRequest("dctListPeople", ages); ObjectCallback callback = new ObjectCallback() ... Hub.instance.getDatabase().submit(request, callback); Finally, to get the request to the database call the “submit” method and pass in the request and callback. Your result, even if it is just an error message, will be presented in the callback’s “process” method.

Request-Response in Schema <Procedure Name="dctListPeople" Execute="listPeople^dctToyTest"> <Description> Get a list of names of all people in test data. Optionally apply an age range filter </Description> <RecRequest> <Field Name="MinAge" Type="Integer" /> <Field Name="MaxAge" Type="Integer" /> </RecRequest> <ListResponse Type="String" /> </Procedure> A DivConq schema file holds custom data types, table declarations, stored procedure declarations and more. Above is just one snipped from the schema file showing the declaration for the stored procedure “dctListPeople”.

Request-Response in Schema <Procedure Name="dctListPeople" Execute="listPeople^dctToyTest"> <Description> Get a list of names of all people in test data. Optionally apply an age range filter </Description> <RecRequest> <Field Name="MinAge" Type="Integer" /> <Field Name="MaxAge" Type="Integer" /> </RecRequest> <ListResponse Type="String" /> </Procedure> Key elements here are the Request and Response which provide the validation rules for this procedure. Expect either a RecRequest (RecordStruct) or a ListRequest (ListStruct) for request – those are our options for request parameters. Likewise, expect a RecResponse or a ListResponse for the response.

Request-Response Example Request (Params) Examples a: { “MinAge”: 30, “MaxAge”: 48 } b: { “MaxAge”: 48 } c: null Response Examples a: [ “Jim”, “Beth”, “Sandy” ] b: [ ] Note that the params are not marked as required (in the schema), so any of the three examples for request are valid. The response is a list of strings. No minimum is given, so a list of zero is valid.

Why the Focus on JSON Windows User w/ Web Browser Linux Box Java App w/ DivConq MUMPS MUMPS Process Your Application Code DivConq Database Interface MUMPS Process External App on Linux DivConq Web Server (HTTP + Web Sockets) MUMPS Process DivConq Schema There are many reasons why JSON – one of the best is interoperability with web apps and other external applications. Through HTTP or WebSocket calls JSON parameters can be sent and JSON results can be returned. To minimize interoperability hassles DivConq favors JSON-like structures throughout.

Request in MUMPS Java Request (Params) { “MinAge”: 30, “MaxAge”: 48 } MUMPS Params Params(“MinAge”)=30 Params(“MaxAge”)=48 JSON can be adopted to MUMPS structures without much effort, details in a future presentation. As far as this overview is concerned, the key point is that JSON-like structures get transformed into MUMPS structures before the stored procedure is called.

MUMPS Procedure Schema Declaration MUMPS Code <Procedure Name="dctListPeople" Execute="listPeople^dctToyTest"> MUMPS Code listPeople ; ; w StartList ; start list of people w ScalarStr_“Jim” ; write a scalar w ScalarStr_“Beth” ; write another scalar w EndList ; end list of people quit The schema tells us what MUMPS routine and function to call. Above is a hint at what the code has to do – return a list of strings. Note how the result from the procedure is sent back to Java by using the “write” command.

MUMPS Procedure Logic listPeople n id,minage,maxage s minage=Params("MinAge"),maxage=Params("MaxAge") ; w StartList ; start list of people (name only) f s id=$o(^dctData("People",id)) q:id="" d . i (minage'="")&(^dctData("People",id,"Age")<minage) q . i (maxage'="")&(^dctData("People",id,"Age")>maxage) q . w ScalarStr_^dctData("People",id,"Name") w EndList ; end list of people quit You’ll need to review the dctToyTest routine to get the details on this example, but what you can see here is that we loop through all the people an apply the (optional) filter. People who are not filtered are returned as scalars (just names) in the list.

Result in Java ObjectCallback callback = new ObjectCallback() { @Override public void process(ObjectResult result) { if (result.hasErrors()) { System.out.println("Error in List"); return; } ListStruct names = result.getResultAsList(); for (Struct item : names.getItems()) System.out.println("Name: " + item.toString()); }; Back in Java you can process the result via ListStruct by looping all the items. We know, because of the schema validation and the call to “hasErrors” that our items are all just strings. There are a few ways to work with a string item, but certainly calling “toString” will work.

Conclusion There is a lot more to learn about stored procedures, but now you have an overview of how it works as well as some of the design philosophy.