<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DivConq Framework</title>
	<atom:link href="http://www.divconq.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.divconq.com</link>
	<description>Next Generation MUMPS + Java Application Framework</description>
	<lastBuildDate>Fri, 30 Mar 2012 13:01:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Quiet but Busy</title>
		<link>http://www.divconq.com/2012/quiet-but-busy/</link>
		<comments>http://www.divconq.com/2012/quiet-but-busy/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 13:00:23 +0000</pubDate>
		<dc:creator>Andy_White</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.divconq.com/?p=701</guid>
		<description><![CDATA[I&#8217;ve been quiet lately, but my day to day projects have taken the framework forward in many areas. Although 0.5.0 is not yet ready, big parts of the future versions are coming together. Here is a status update: Version 0.5.0 (in progress) dcDB &#8211; add support for dcSimple &#8211; Put, Get, Delete, Query (no progress) [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been quiet lately, but my day to day projects have taken the framework forward in many areas.  Although 0.5.0 is not yet ready, big parts of the future versions are coming together.  Here is a status update:</p>
<h1>Version 0.5.0 (in progress)</h1>
<p></p>
<p>dcDB &#8211; add support for dcSimple &#8211; Put, Get, Delete, Query  (no progress)</p>
<p>dcDB &#8211; improve dcTables indexing, consolidate schema globals, support table instances (provide multi-homed / multi-domain support to apps)  (2/3 done)</p>
<p>Users/Groups &#8211; improve support in task context  (mostly done)</p>
<p>Locale Formatting &#8211; add number and date formatting to Java and MUMPS  (1/2 done)</p>
<p>TimeZones/Chronology &#8211; add timezone support to Java and MUMPS, basic hooks for Chronology  (1/2 done for US zones)</p>
<h1>Version 0.6.0 (in progress)</h1>
<p></p>
<p>dcServiceBus &#8211; support local (same JVM) service calls and schema support  (done)</p>
<p>dcWeb &#8211; support remote service bus calls over web sockets, provide a Java client to use the web sockets interface  (done)</p>
<p>dcClaims &#8211; provide minimal claims services &#8211; for local server or local squad.  (not started)</p>
<h1>Version 0.7.0 (in progress)</h1>
<p></p>
<p>dcWeb &#8211; add HTTP RPC support for remote service bus calls.  add service description language.  (1/2 done)</p>
<p>dcWeb &#8211; provide web app framework based on dcQoo.  (2/3 done)</p>
<p>dcAdmin &#8211; first release of admin tool, supports dcDB query and schema review  (not started)</p>
<h1>Version 0.8.0 (in progress)</h1>
<p></p>
<p>dcWeb &#8211; Improve support for web frameworks, both dcQoo and dcLight.  (mostly there)</p>
<p>dcRepository &#8211; compile developer repository, support master/project repository  (not started)</p>
<p></p>
<p>At some point I need to buckle down and complete 0.5.0, but so far my user base is pushing too hard :)  At this rate I would expect to see a 0.9.0 release in Q3, depending on how involved I get in Common Transfer Protocol then maybe Q4 version 0.9.5 with CTP.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.divconq.com%2F2012%2Fquiet-but-busy%2F&amp;title=Quiet%20but%20Busy" id="wpa2a_2"><img src="http://www.divconq.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.divconq.com/2012/quiet-but-busy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Design Notes on RPC Calls</title>
		<link>http://www.divconq.com/2012/design-notes-on-rpc-calls/</link>
		<comments>http://www.divconq.com/2012/design-notes-on-rpc-calls/#comments</comments>
		<pubDate>Mon, 19 Mar 2012 19:05:31 +0000</pubDate>
		<dc:creator>Andy_White</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.divconq.com/?p=696</guid>
		<description><![CDATA[Detailed in the link below are DivConq&#8217;s plans for RPC support. These plans are incomplete (there are also service discovery and service schema features) however this does cover network layer neutrality and how everything from small messages to large file transfers may route through this new protocol called Common Transfer Protocol. Download PDF: https://s3.amazonaws.com/divconqframework/docs/ctp.pdf Or [...]]]></description>
			<content:encoded><![CDATA[<p>Detailed in the link below are DivConq&#8217;s plans for RPC support.  These plans are incomplete (there are also service discovery and service schema features) however this does cover network layer neutrality and how everything from small messages to large file transfers may route through this new protocol called Common Transfer Protocol.</p>
<p>Download PDF:</p>
<p><a href="https://s3.amazonaws.com/divconqframework/docs/ctp.pdf">https://s3.amazonaws.com/divconqframework/docs/ctp.pdf</a></p>
<p>Or view on SlideShare:</p>
<p><a href="http://www.slideshare.net/etimeline/ctp-12079818">http://www.slideshare.net/etimeline/ctp-12079818</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.divconq.com%2F2012%2Fdesign-notes-on-rpc-calls%2F&amp;title=Design%20Notes%20on%20RPC%20Calls" id="wpa2a_4"><img src="http://www.divconq.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.divconq.com/2012/design-notes-on-rpc-calls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More Stored Procedures and MUMPS</title>
		<link>http://www.divconq.com/2012/more-stored-procedures-and-mumps/</link>
		<comments>http://www.divconq.com/2012/more-stored-procedures-and-mumps/#comments</comments>
		<pubDate>Wed, 29 Feb 2012 22:31:07 +0000</pubDate>
		<dc:creator>Andy_White</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.divconq.com/?p=693</guid>
		<description><![CDATA[DivConq has just released an presentation delving into details of Stored Procedure development within DivConq Framework. This includes examples on how to pass data to a stored procedure and how to return data from a stored procedure. It further includes how to pass status or debugging messages from stored procedure, including message localization. Download : [...]]]></description>
			<content:encoded><![CDATA[<p>DivConq has just released an presentation delving into details of Stored Procedure development within DivConq Framework.  This includes examples on how to pass data to a stored procedure and how to return data from a stored procedure.  It further includes how to pass status or debugging messages from stored procedure, including message localization.</p>
<p>Download : <a target="_BLANK" href="https://s3.amazonaws.com/divconqframework/docs/dcDB+Stored+Procedures+3.pdf">Download PDF</a> or <a target="_BLANK" href="http://www.slideshare.net/etimeline/more-stored-procedures-and-mumps-for-divconq">View on SlideShare</a>.</p>
<p>The presentation covers:<br />
 1) Schema for Stored Procedures<br />
 2) Parameter data structures<br />
 3) Return data structures<br />
 4) UPDATE data example</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.divconq.com%2F2012%2Fmore-stored-procedures-and-mumps%2F&amp;title=More%20Stored%20Procedures%20and%20MUMPS" id="wpa2a_6"><img src="http://www.divconq.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.divconq.com/2012/more-stored-procedures-and-mumps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Content Management System</title>
		<link>http://www.divconq.com/2012/content-management-system/</link>
		<comments>http://www.divconq.com/2012/content-management-system/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 14:56:47 +0000</pubDate>
		<dc:creator>Andy_White</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.divconq.com/?p=688</guid>
		<description><![CDATA[Progress on DivConq Framework 0.5 is still being made. We are currently building a CMS on the DivConq Framework which is needed by one of our partner projects. The CMS will also be open source and available for download at this site. Building an application using DivConq also helps serve as a sanity check for [...]]]></description>
			<content:encoded><![CDATA[<p>Progress on DivConq Framework 0.5 is still being made.  We are currently building a CMS on the DivConq Framework which is needed by one of our partner projects.  The CMS will also be open source and available for download at this site.  Building an application using DivConq also helps serve as a sanity check for the Framework design, so although it may slow progress a little it will help mature the Framework.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.divconq.com%2F2012%2Fcontent-management-system%2F&amp;title=Content%20Management%20System" id="wpa2a_8"><img src="http://www.divconq.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.divconq.com/2012/content-management-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Date Time Plans</title>
		<link>http://www.divconq.com/2012/date-time-plans/</link>
		<comments>http://www.divconq.com/2012/date-time-plans/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 16:02:26 +0000</pubDate>
		<dc:creator>Andy_White</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.divconq.com/?p=682</guid>
		<description><![CDATA[Neither the MUMPS standard, nor the GT.M implementation, come with much date time support. Even if it did it would differ from Java&#8217;s support and from the various Javascript libraries out there. For DivConq we want to provide consistent date time formatting and parsing for MUMPS (your stored procedures and queries), for Java (your business [...]]]></description>
			<content:encoded><![CDATA[<p>Neither the MUMPS standard, nor the GT.M implementation, come with much date time support.  Even if it did it would differ from Java&#8217;s support and from the various Javascript libraries out there.  For DivConq we want to provide consistent date time formatting and parsing for MUMPS (your stored procedures and queries), for Java (your business logic and EDI) and for Javascript (your web UI).  Further, as already mentioned elsewhere, we support the BigDateTime data type for dates from -50 billion to +50 billion years.  </p>
<p>Our date time formatting support starts within MUMPS.  Recent releases of DivConq have considerable support for querying the database, but date time is always returned in the internal format (ISO 8601) or in the internal BigDateTime format &#8211; and also always store times using the UTC timezone.  In DivConq every request to the database silently carries the current task&#8217;s (user&#8217;s) timezone (chronology) and locale.  Therefore we have the info we need format a date time within MUMPS.  Our current work is to code support for chronologies and timezones.</p>
<p><span id="more-682"></span></p>
<p>By chronology we mean Gregorian calendar, Julian calendar, Mayan calendar and such.  For starters we are supporting the ISO (proleptic Gregorian) calendar.  It is easy to calculate because it has a year 0 and follows the Gregorian rules back into time indefinitely.  We plan to add support for some additional calendars plus add the hooks for developers to drop in support for their own custom calendars.  And we plan to expand customizable calendar support to Java and Javascript.  Until we do, we suggest using the Joda Time library as it is generally supported in DivConq as an alternative to BigDateTime.  </p>
<p>Beyond picking the calendar, the chronology contains additional details such as timezone.  The  support we are adding for ISO (proleptic Gregorian) calendar includes support for timezones.  In general the approach should work for any timezone, but our initial tests are focused on USA 2007 timezone rules.  Since all dates in dcTables are stored as UTC, it makes formatting easier &#8211; there are no DST rules for UTC.</p>
<p>The next release of DivConq will support a minimal set of locale based date time and number formatting options.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.divconq.com%2F2012%2Fdate-time-plans%2F&amp;title=Date%20Time%20Plans" id="wpa2a_10"><img src="http://www.divconq.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.divconq.com/2012/date-time-plans/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stored Procedures and MUMPS</title>
		<link>http://www.divconq.com/2012/stored-procedures-and-mumps/</link>
		<comments>http://www.divconq.com/2012/stored-procedures-and-mumps/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 02:05:26 +0000</pubDate>
		<dc:creator>Andy_White</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.divconq.com/?p=678</guid>
		<description><![CDATA[DivConq has just released an presentation delving into details of Stored Procedure development within DivConq Framework. This includes examples on how to pass data to a stored procedure and how to return data from a stored procedure. It further includes how to pass status or debugging messages from stored procedure, including message localization. Download : [...]]]></description>
			<content:encoded><![CDATA[<p>DivConq has just released an presentation delving into details of Stored Procedure development within DivConq Framework.  This includes examples on how to pass data to a stored procedure and how to return data from a stored procedure.  It further includes how to pass status or debugging messages from stored procedure, including message localization.</p>
<p>Download : <a target="_BLANK" href="https://s3.amazonaws.com/divconqframework/docs/dcDB+Stored+Procedures+2.pdf">Download PDF</a> or <a target="_BLANK" href="http://www.slideshare.net/etimeline/stored-procedures-and-mumps-for-divconq">View on SlideShare</a>.</p>
<p>The presentation covers:<br />
 1) Java Struct Parameters to MUMPS structure conversions<br />
 2) returning JSON-Like data structures<br />
 3) Error messages<br />
 4) Localized messages</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.divconq.com%2F2012%2Fstored-procedures-and-mumps%2F&amp;title=Stored%20Procedures%20and%20MUMPS" id="wpa2a_12"><img src="http://www.divconq.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.divconq.com/2012/stored-procedures-and-mumps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Data Structures in DivConq</title>
		<link>http://www.divconq.com/2012/data-structures-overview/</link>
		<comments>http://www.divconq.com/2012/data-structures-overview/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 23:49:47 +0000</pubDate>
		<dc:creator>Andy_White</dc:creator>
				<category><![CDATA[DivConq]]></category>
		<category><![CDATA[Elastic Architecture]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[MUMPS]]></category>

		<guid isPermaLink="false">http://www.divconq.com/?p=672</guid>
		<description><![CDATA[DivConq has just released an introductory presentation covering the JSON-Like data structures used within DivConq Framework. Download PDF or View on SlideShare. The presentation covers: 1) JSON Compatibility 2) Creating data structures 3) Accessing data structures 4) Use of dcSchema for data validation]]></description>
			<content:encoded><![CDATA[<p>DivConq has just released an introductory presentation covering the JSON-Like data structures used within DivConq Framework.</p>
<p><a target="_BLANK" href="https://s3.amazonaws.com/divconqframework/docs/Data+Types.pdf">Download PDF</a> or <a target="_BLANK"  href="http://www.slideshare.net/etimeline/data-typesstructures-in-divconq">View on SlideShare</a>.</p>
<p>The presentation covers:<br />
1) JSON Compatibility<br />
2) Creating data structures<br />
3) Accessing data structures<br />
4) Use of dcSchema for data validation</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.divconq.com%2F2012%2Fdata-structures-overview%2F&amp;title=Data%20Structures%20in%20DivConq" id="wpa2a_14"><img src="http://www.divconq.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.divconq.com/2012/data-structures-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stored Procedure Overview</title>
		<link>http://www.divconq.com/2012/stored-procedure-overview/</link>
		<comments>http://www.divconq.com/2012/stored-procedure-overview/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 23:15:02 +0000</pubDate>
		<dc:creator>Andy_White</dc:creator>
				<category><![CDATA[DivConq]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[MUMPS]]></category>

		<guid isPermaLink="false">http://www.divconq.com/?p=666</guid>
		<description><![CDATA[DivConq has just released an introductory presentation on Stored Procedure use within DivConq Framework. Download Power Point or View on SlideShare. The presentation covers: 1) how DivConq connects to MUMPS 2) how to create a request 3) the request-response flow 4) Java example code 5) schema example declaration 6) MUMPS example code 7) JSON and [...]]]></description>
			<content:encoded><![CDATA[<p>DivConq has just released an introductory presentation on Stored Procedure use within DivConq Framework.</p>
<p><a href="https://s3.amazonaws.com/divconqframework/docs/dcDB+Stored+Procedures.pptx">Download Power Point</a> or <a href="http://www.slideshare.net/etimeline/dcdb-overview-of-stored-procedures">View on SlideShare</a>.</p>
<p>The presentation covers:</p>
<p>1) how DivConq connects to MUMPS<br />
2) how to create a request<br />
3) the request-response flow<br />
4) Java example code<br />
5) schema example declaration<br />
6) MUMPS example code<br />
7) JSON and interoperability</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.divconq.com%2F2012%2Fstored-procedure-overview%2F&amp;title=Stored%20Procedure%20Overview" id="wpa2a_16"><img src="http://www.divconq.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.divconq.com/2012/stored-procedure-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DivConq Framework 0.4.8 Released</title>
		<link>http://www.divconq.com/2012/divconq-framework-0-4-8-released/</link>
		<comments>http://www.divconq.com/2012/divconq-framework-0-4-8-released/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 22:30:43 +0000</pubDate>
		<dc:creator>Andy_White</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.divconq.com/?p=656</guid>
		<description><![CDATA[This week we released version 0.4.8 of our DivConq Framework. This release extends the capabilities of our dcTables feature. Download. Our open-source DivConq Framework brings a sophisticated but accessible Java library to MUMPS developers with the intention of getting the most out of the pairing. In version 0.4.5 we supplemented our powerful stored procedures feature [...]]]></description>
			<content:encoded><![CDATA[<p>This week we released version 0.4.8 of our DivConq Framework.   This release extends the capabilities of our dcTables feature. <a href="https://s3.amazonaws.com/divconqframework/release/divconq-0.4.8.zip">Download</a>.</p>
<p>Our open-source DivConq Framework brings a sophisticated but accessible Java library to MUMPS developers with the intention of getting the most out of the pairing.  In version 0.4.5 we supplemented our powerful stored procedures feature with dcTables, a feature that aims to provide the rapid development ideal of relational databases to MUMPS.  With version 0.4.8 we round out dcTables by adding support for a SELECT like command.  dcTables already supported commands similar to INSERT, UPDATE and DELETE.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.divconq.com%2F2012%2Fdivconq-framework-0-4-8-released%2F&amp;title=DivConq%20Framework%200.4.8%20Released" id="wpa2a_18"><img src="http://www.divconq.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.divconq.com/2012/divconq-framework-0-4-8-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to Stored Procedures Part Two</title>
		<link>http://www.divconq.com/2011/intro-to-stored-procedures-part-two/</link>
		<comments>http://www.divconq.com/2011/intro-to-stored-procedures-part-two/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 23:45:59 +0000</pubDate>
		<dc:creator>Andy_White</dc:creator>
				<category><![CDATA[DivConq]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[MUMPS]]></category>

		<guid isPermaLink="false">http://www.divconq.com/?p=582</guid>
		<description><![CDATA[In Part One of this series we got to see some simple examples of M code being used as Stored Procedures from Java. We saw that how Stored Procedures are named and how to use the name to call it from Java or from the M command prompt. Part two will cover a deeper example [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="2011/intro-to-stored-procedures-part-one">Part One</a> of this series we got to see some simple examples of M code being used as Stored Procedures from Java.  We saw that how Stored Procedures are named and how to use the name to call it from Java or from the M command prompt.</p>
<p>Part two will cover a deeper example that involves storing and reading data in a M Global &#8211; similar to how you may end up using the Stored Procedures feature your applications.  In the process we&#8217;ll cover in more detail how to write the M code, how to declare the procedure in dcSchema, how to call from Java and how to process the return values.</p>
<p><span id="more-582"></span></p>
<p>View the M routine dctToyTest.m.  Most of the code is for Stored Procedure calls, but at the top are &#8220;setup&#8221; and &#8220;cleanup&#8221; functions.  This example needs setup, so before we go any further lets run that from the M prompt.</p>
<pre class="brush:js">
GTM>d setup^dctToyTest

GTM>
</pre>
<p>Verify that the global has been loaded, compare the code in the &#8220;setup&#8221; function with what you see in the global:</p>
<pre class="brush:js">
GTM>zwr ^dctData
^dctData("People",10000,"Age")=8
^dctData("People",10000,"Friends",1)=10001
^dctData("People",10000,"Friends",2)=10002
^dctData("People",10000,"Name")="Sally"
^dctData("People",10000,"Toys",1)="Legos"
^dctData("People",10000,"Toys",2)="Puzzle"
...

GTM>
</pre>
<p>There are now 6 people in our database.  In addition to the records in ^dctData, there is also a ^dtcIndex which holds the indexes for the Toys and Friends fields.   Sally, the example record above, has 2 friends and 2 toys.  The indexes for her fields look like this:</p>
<pre class="brush:js">
^dctIndex("Friends",10001,10000)=1
^dctIndex("Friends",10002,10000)=1
^dctIndex("Toys","Legos",10000)=1
^dctIndex("Toys","Puzzle",10000)=1
</pre>
<p>The test data and index globals are not well designed, so the point here is just to see how the example works &#8211; not to mimic the design.  When we look at the dcTables feature later the we&#8217;ll discuss design goals.  That said, what we see here is that if we have a person id such as 1002 (Ginger) we can easily find who has friended that person.  By looping the index &#8211; s friend=$o(^dctIndex(&#8220;Friends&#8221;,10002,friend)) &#8211; we can find all those people.  Conversely, the people Ginger has friended will be in ^dctData(&#8220;People&#8221;,10000,&#8221;Friends&#8221;,n)=Friend Id.</p>
<p>Likewise we can find all the people who like a particular toy by looping, for example who likes Legos: s person=$o(^dctIndex(&#8220;Toys&#8221;,&#8221;Legos&#8221;,person)).  If these concepts don&#8217;t make sense you need to resume review MUMPS data structures.</p>
<p>Lets delve into the first Stored Procedure, it just returns a list (JSON Array) of names (strings).  All 6 people are listed:</p>
<pre class="brush:js">
GTM>d local^dcConn("QUERY dctListPeople")

Data:
:[ : Sally: Chad: Ginger: Kyle: Betty: Mike] !
Messages:
:[ ] !
GTM>
</pre>
<p>Recall that we find the M routine name in the ^Proc global.</p>
<pre class="brush:js">
GTM>zwr ^Proc
...
^Proc("dctListPeople")="listPeople^dctToyTest"
...

GTM>
</pre>
<p>So we should look at the &#8220;listPeople&#8221; function in &#8220;dctToyTest&#8221;.  The first few lines handle parameters passed to the stored procedure.  Parameters will (typically) be provided to procedures via the local variable &#8220;Params&#8221;.  Parameters can be complex M structures, but typically they are just key and value pairs such as MinAge and MaxAge.  When these parameters are present they limit the list of names returned so that only people within the range appear.</p>
<pre class="brush:js">
listPeople n id,minage,maxage
 s minage=Params("MinAge"),maxage=Params("MaxAge")
 s:minage="" minage=0
 s:maxage="" maxage=200
</pre>
<p>Note that if the parameter keys are not present we default to a value.  Another option would be to log an error and return &#8211; something like this:  <i>i minage=&#8221;" d err^dcConn(90010) quit</i>.  We&#8217;ll cover error handling in a future part of this series.  But it is useful to know these rules:  </p>
<p>a) You do not have to return any data at all from a stored proc<br />
b) If you find that something expected is missing (parameters, data) then you may log and error or warning, that message will be presented to the calling code (Java or M)<br />
c) If no error or warning is logged then the procedure is assumed to have run correctly even if no data was returned<br />
d) It is good practice to check for errors before returning any data, as much as possible<br />
e) When you do want to return data from a procedure you must return it either in a List or a Record.  Your structures must be well formed and syntactically correct.</p>
<p>Lists and Records have a definite start and end, and you must make sure they are well formed (there is always an end for every start).</p>
<pre class="brush:js">
 w StartList		; start list of people
 ;
 f  s id=$o(^dctData("People",id)) q:id=""  d
 . i (^dctData("People",id,"Age")&lt;minage)!(^dctData("People",id,"Age")>maxage) q
 . ;
 . w ScalarStr_^dctData("People",id,"Name")
 ;
 w EndList		; end list of people
 ;
 quit
</pre>
<p>The start and end of the list is fairly obvious.  Also by now the &#8220;for&#8221; loop should make sense.  Inside the loop we first check to see if the person&#8217;s age is less than or greater than the age range provided to the procedure.  If it is in the correct range we go to the next lines and write out the name.</p>
<p>Note that every item in a list must be preceded with a &#8220;Scalar&#8221;.  Typically the Scalar is a &#8220;ScalarStr&#8221; if the following value is a string, &#8220;ScalarInt&#8221; if the following value is an integer or &#8220;ScalarDec&#8221; if the following value is a decimal.</p>
<p>Procedures may return complex data structures &#8211; Records in Lists, Lists in Lists, Records in Fields and Lists in Fields.  Very much like JSON does.  Consider the procedure &#8220;dctGetPeople&#8221; which links us to the &#8220;getPeople&#8221; function in &#8220;dctToyTest&#8221;.  Here is a description of the return value for this procedure:</p>
<pre class="brush:js">
 [
     {
        "Id": |int, person id|,
        "Name": |string, person name|,
        "Age": |int, person age|,
        "Toys": [
	        |string, toy name|
        ],
        "Friends": [
            {
                "Name": |string, person name|,
                "Age": |int, person age|
            }
        ],
        "FriendedBy": [
            {
                "Name": |string, person name|,
                "Age": |int, person age|
            }
        ]
     }
 ]
</pre>
<p>We see that Friends are records inside of a list, the list is inside a field, the field is in a record, the record is in a list.  A complex structure, but not too hard to code in M.  Run it just for kicks:</p>
<pre class="brush:js">
GTM>d local^dcConn("QUERY dctGetPeople")

Data:
:[ :{ , Id: 10000, Name: Sally, Age: 8, Toys:[ : Legos: Puzzle] , Friends:[ :{ ,
 Name: Chad, Age: 8} :{ , Name: Ginger, Age: 9} ] , FriendedBy:[ :{ , Name: Chad
, Age: 8} ] } :{ , Id: 10001, Name: Chad, Age: 8, Toys:[ : Kite: Playdough] , Fr
iends:[ :{ , Name: Sally, Age: 8} :{ , Name: Ginger, Age: 9} ] , FriendedBy:[ :{
 , Name: Sally, Age: 8} ] } :{ , Id: 10002, Name: Ginger, Age: 9, Toys:[ : Bike:
 Softball] , Friends:[ :{ , Name: Kyle, Age: 10} :{ , Name: Mike, Age: 9} ] , Fr
iendedBy:[ :{ , Name: Sally, Age: 8} :{ , Name: Chad, Age: 8} :{ , Name: Betty,
Age: 9} ] } :{ , Id: 10003, Name: Kyle, Age: 10, Toys:[ : Softball Bat] , Friend
s:[ ] , FriendedBy:[ :{ , Name: Ginger, Age: 9} :{ , Name: Mike, Age: 9} ] } :{
, Id: 10004, Name: Betty, Age: 9, Toys:[ : Jump Rope: Softball Glove] , Friends:
[ :{ , Name: Ginger, Age: 9} :{ , Name: Mike, Age: 9} ] , FriendedBy:[ :{ , Name
: Ginger, Age: 9} ] } :{ , Id: 10005, Name: Mike, Age: 9, Toys:[ : Frisbee] , Fr
iends:[ :{ , Name: Kyle, Age: 10} ] , FriendedBy:[ :{ , Name: Ginger, Age: 9} :{
 , Name: Betty, Age: 9} ] } ] !
Messages:
:[ ] !
GTM>
</pre>
<p>Procedures do not have to have any parameters, consider the first lines of &#8220;getPeople&#8221;.</p>
<pre class="brush:js">
getPeople n id,tnum,fnum,fid
 w StartList		; start list of people
 ;
</pre>
<p>We jump right into writing out a list.  And at the end we be sure to end our list:</p>
<pre class="brush:js">
 ;
 w EndList		; end list of people
 ;
 quit
</pre>
<p>The rest should fairly easily to comprehend, just do loops within loops to get at all the data you want.  We do use the index global here, lets peek at that code (which is already in a loop on the records):</p>
<pre class="brush:js">
 . w Field_"FriendedBy"_StartList	; friended by list
 . f  s fnum=$o(^dctIndex("Friends",id,fnum)) q:fnum=""  d
 . . w StartRec	; friend info
 . . w Field_"Name"_ScalarStr_^dctData("People",fnum,"Name")
 . . w Field_"Age"_ScalarInt_^dctData("People",fnum,"Age")
 . . w EndRec	; friend info
 . w EndList					; end friended by list
</pre>
<p>Note the Start and End list for the friended by field.  We just loop through the index and write out a small record (inside the List) for each friended by entry.</p>
<p>Lets run this via the Java Connector.  Run testdb again, as you did in the <a href="2011/getting-connected-with-divconq/">Getting Connected post</a>.</p>
<pre class="brush:js">
D:\dev\divconq\template>.\bin\run.bat testdb

...
option 8
...

-----------------------------------------------
   Toy Database Menu
-----------------------------------------------
0)  Main Menu
1)  List People Names
2)  List Toys
3)  List People in Tabular
4)  List People in Complex
5)  List People directly to file (Json)
6)  List People directly to file (Yaml)
7)  Add Person
1
MinAge filter [empty for no filter]: 5
MaxAge filter [empty for no filter]: 8

dctListPeople Response:
 [
        "Sally",
        "Chad"
 ]
</pre>
<p>And now for the more complex example, run option 4 and see the data coming back from the procedure formatted in JSON.</p>
<p>As mentioned earlier, Java calls the procedure names &#8220;dctListToys&#8221; and &#8220;dctGetPeople&#8221;.  We know that the ^Proc global holds the mapping for the procedure name to the function name in M.  But who sets up the mapping?</p>
<p>The answer is &#8211; the developer does.  And so this brings us to a whole new topic in DivConq, Packages.  Applications written using DivConq as assembled by combining Packages.  Each Package contains Java and/or M code and adds some functionality to the overall application.</p>
<p>In a sense a Package is like an &#8220;add-on&#8221; only the whole application is composed of &#8220;add-ons&#8221;, separate units of functionality that may be installed or not.  If you are familiar with OSGi then a package is somewhat similar in concept (we don&#8217;t use separation via class-loaders yet though, lets see what Java 8 brings).  Also, to some extent, a WAR file is similar to a Package.</p>
<p>In any event, there is 1 core Package which all applications must have &#8211; it is &#8220;dcCore&#8221;.  Combine this with your own Package &#8220;myApp&#8221; and you have all you need to make a distribution of your application.  But if you choose to allow it, your customers may drop in other packages (their own customizations or third-party) on top of your install to add more functionality.</p>
<p>One of the great things about DivConq is that the contents of one package may override the contents of another package.  Thus, if a customer dislikes images or locale translations or whatever in your application, it is fairly easy to create an override and put it in another package.  This keeps their stuff separate from your distribution, and it also makes it very easy to identify the overrides during an update.  You update installer can say to the user &#8220;we see you overrode X, but we changed X since your last install.&#8221;  It takes work to setup that up in your installer, but the effort in checking for overrides is minimal once you know what you want to provides hints on.</p>
<p>This brings us to the &#8220;dcTest&#8221; package.  This package would not be distributed with your application, it is just here to provide examples to developers learning DivConq.  So &#8220;dcTest&#8221; keeps &#8220;dcCore&#8221; clean by keeping almost all the example files separate.</p>
<p>Look at your copy of the dcTest package in the Template folder: &#8220;template/packages/dcTest&#8221;.  In here is the &#8220;package.xml&#8221; file that describes the package &#8211; more on that later.  There is also an &#8220;m&#8221; folder that contains the M routines that dcTest relies on.  Now look in &#8220;all/schema&#8221; to find the schema declarations.</p>
<p>Open the schema file and look for a Procedure element with Name=&#8221;dctListPeople&#8221;.  Here is what that looks like:</p>
<pre class="brush:js">
&lt;Procedure Name=&quot;dctListPeople&quot; Execute=&quot;listPeople^dctToyTest&quot;&gt;
	&lt;Description&gt;
		Get a list of names of all people in test data.
		Optionally add in an age range filter
	&lt;/Description&gt;
	&lt;RecRequest&gt;
		&lt;Field Name=&quot;MinAge&quot; Type=&quot;Integer&quot; /&gt;
		&lt;Field Name=&quot;MaxAge&quot; Type=&quot;Integer&quot; /&gt;
	&lt;/RecRequest&gt;
	&lt;ListResponse Type=&quot;String&quot; /&gt;
&lt;/Procedure&gt;
</pre>
<p>Every stored procedure in DivConq needs a definition like this.  The definition will be in a schema file within the Package you are developing.  For example, if you are coding some Divconq tests in template then you&#8217;d probably be editing the schema file &#8220;template/packages/dctTemplate/all/schema/schema.xml&#8221;.</p>
<p>Stored procedures need definitions so that Java can determine that it is calling with the right parameters and that the correct data structure is being returned by the procedure.  You can see in the Execute attribute how the name gets mapped to the M function.  </p>
<p>Recall when you did &#8220;run.bat sync&#8221; and updated the M globals (option 2).  The sync utility copies information about the stored procedures to M.  So first you edit the schema, then you run sync, then you may call your procedure.</p>
<p>A future post will expand on how to make schema definitions, but for now look just at how we declare the request:</p>
<pre class="brush:js">
	&lt;RecRequest&gt;
		&lt;Field Name=&quot;MinAge&quot; Type=&quot;Integer&quot; /&gt;
		&lt;Field Name=&quot;MaxAge&quot; Type=&quot;Integer&quot; /&gt;
	&lt;/RecRequest&gt;
</pre>
<p>RecRequest means we will pass in a Record (not a List) and that we&#8217;ll have MinAge and MaxAge as possible fields.  So within M the Params(&#8220;MinAge&#8221;) looks like key value, but within Java/dcSchema we think of that as a record with fields.  There is no Required=&#8221;True&#8221; with these fields, as such they may be absent from the call in Java.</p>
<p>And look at how we declare the response:</p>
<pre class="brush:js">
	&lt;ListResponse Type=&quot;String&quot; /&gt;
</pre>
<p>ListResponse (not RecResponse) means we expect a list &#8211; the Type attribute tells use it will be a list of String.  Each String is a single name, of course.</p>
<p>This brings us to the final example in this part of the Stored Procedure series, a call in Java.</p>
<pre class="brush:js">
RecordStruct ages = new RecordStruct();
ages.setField("MinAge", 3);
ages.setField("MaxAge", 8);

QueryRequest lpr = new QueryRequest("dctListPeople", ages);
</pre>
<p>Although we have not yet covered RecordStruct, you can probably guess that this is what we mean when we declare the parameter as being a &#8220;RecRequest&#8221; &#8211; a record.  Yes, a record with 2 fields just as declared in dcSchema.  The parameter is passed into the QueryRequest object, along with the procedure name, and we have all that we need to make a call to the database.</p>
<p>We&#8217;ll cover more about database calls in the next part.  Along with that we&#8217;ll cover error handling in stored procedures (including localization) and review a stored procedure for updating globals.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.divconq.com%2F2011%2Fintro-to-stored-procedures-part-two%2F&amp;title=Introduction%20to%20Stored%20Procedures%20Part%20Two" id="wpa2a_20"><img src="http://www.divconq.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.divconq.com/2011/intro-to-stored-procedures-part-two/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

