{"id":1052,"date":"2013-05-15T17:39:18","date_gmt":"2013-05-15T22:39:18","guid":{"rendered":"http:\/\/www.thefillmoregroup.com\/blog\/?p=1052"},"modified":"2013-05-15T17:48:09","modified_gmt":"2013-05-15T22:48:09","slug":"keeping-it-in-the-family-batch-movement-of-data-between-db2-databases-andor-subsystems","status":"publish","type":"post","link":"https:\/\/www.thefillmoregroup.com\/blog\/?p=1052","title":{"rendered":"Keeping it in the Family: Batch Movement of Data Between DB2 Databases and\/or Subsystems"},"content":{"rendered":"<p>A few weeks ago a customer was confronted with a common challenge.\u00a0 They had to move terabytes of data &#8211; billions of rows &#8211; from DB2 for LUW to DB2 for z\/OS.\u00a0 I suggested a &#8220;cursor-based load&#8221; (aka the &#8220;cross-loader&#8221;).\u00a0 This DB2 for z\/OS DBA team is top-notch, with <em>centuries<\/em> of collective experience, but I\u00a0mostly was met with blank stares.\u00a0 So here&#8217;s the brief refresher (or introduction) I gave them on the cross-loader.<\/p>\n<p>The common method for moving data from\u00a0DB2 for LUW tables to DB2 for z\/OS <em>could<\/em> be a serial process where the data is<\/p>\n<ol>\n<li>extracted from DB2 for LUW<\/li>\n<li>transported to the z\/OS platform<\/li>\n<li>loaded into DB2 for z\/OS<\/li>\n<\/ol>\n<p>This can be done as three discrete steps in a variety of ways.\u00a0 The problem with three discrete steps is the I\/O overhead of landing the data to disk three times: to the local extract file, FTPed to z\/OS, loaded into DB2.\u00a0 In addition, the steps are <em>serial<\/em> (e.g. the extract must complete before the FTP can begin).<\/p>\n<p>\u00a0An alternative is using a cursor-based LOAD (aka the \u201ccross-loader\u201d).\u00a0 The cross-loader has been available in DB2 for z\/OS since v7.<\/p>\n<p>\u00a0Steps to enable the cross-loader:<\/p>\n<ol>\n<li>Set up DRDA definitions in the DB2 Communications Database (CDB) in the DB2 for z\/OS subsystem that will be running the loads (i.e. the \u201ctarget\u201d).<\/li>\n<li>Create DB2 for z\/OS nicknames for the tables to be loaded from the DB2 for LUW source.<\/li>\n<\/ol>\n<p>In the example below the table PAOLOR7.DEPT is a nickname.\u00a0 The LOAD utility jobs can be scheduled to minimize the impact on production workloads.<\/p>\n<p>This would be relatively easy to set up and test in a development environment.\u00a0\u00a0\u00a0This is the fastest, easiest, simplest way to move the\u00a0data to z\/OS.\u00a0 This method will also use the least machine resources.<\/p>\n<p>&nbsp;<\/p>\n<p><em>References for cursor-based load<\/em><\/p>\n<p>DB2 10 for z\/OS Information Center \u201c<a href=\"http:\/\/pic.dhe.ibm.com\/infocenter\/dzichelp\/v2r2\/index.jsp?topic=%2Fcom.ibm.db2z10.doc.ugref%2Fsrc%2Ftpc%2Fdb2z_loadusecrossloaderfunction.htm\" target=\"_blank\">Loading data by using the cross-loader function<\/a>\u201d<\/p>\n<p>Redbook \u201c<a href=\"http:\/\/www.redbooks.ibm.com\/redbooks\/pdfs\/sg246905.pdf\" target=\"_blank\">Moving Data Across the DB2 Family<\/a>\u201d<\/p>\n<p><!--more--><\/p>\n<p>&lt;snippet from Redbook pages 60 &#8211; 61&gt;<\/p>\n<p><strong><em>Declaring a cursor for use with the Cross Loader<\/em><\/strong><\/p>\n<p>The cursor definition has to be put between the EXEC SQL and ENDEXEC keywords in the utility input stream:<\/p>\n<p>EXEC SQL DECLARE cursor-name CURSOR FOR select statement ENDEXEC<\/p>\n<p>In Example 4-11 we declare a cursor for extracting rows with ADMRDEPT = \u2018A00\u2019 from PAOLOR7.DEPT.<\/p>\n<p><em>Example 4-11 Declare a cursor for the Cross Loader<\/em><\/p>\n<p style=\"padding-left: 30px;\">EXEC SQL<\/p>\n<p style=\"padding-left: 30px;\">DECLARE <strong><em>C1<\/em><\/strong> CURSOR FOR<\/p>\n<p style=\"padding-left: 30px;\">SELECT * FROM PAOLOR7.DEPT<\/p>\n<p style=\"padding-left: 30px;\">WHERE ADMRDEPT = &#8216;A00&#8217;<\/p>\n<p style=\"padding-left: 30px;\">ORDER BY 1 ASC<\/p>\n<p style=\"padding-left: 30px;\">ENDEXEC<\/p>\n<p>In Example 4-12 we show how this cursor can now be used in a LOAD statement (Cross Loader.)<\/p>\n<p><em>Example 4-12 Usage of a cursor in the LOAD statement<\/em><\/p>\n<p style=\"padding-left: 30px;\">LOAD DATA<\/p>\n<p style=\"padding-left: 30px;\">INCURSOR <strong><em>C1<\/em><\/strong><\/p>\n<p style=\"padding-left: 30px;\">INTO TABLE PAOLOR2.DEPT<\/p>\n<p>The SQL statement in the declare cursor definition can be any valid SQL statement including joins, unions, data conversions, aggregations, special registers, and UDFs.\u00a0 The source data can be on a local server or remote server using DRDA access.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few weeks ago a customer was confronted with a common challenge.\u00a0 They had to move terabytes of data &#8211; billions of rows &#8211; from DB2 for LUW to DB2 for z\/OS.\u00a0 I suggested a &#8220;cursor-based load&#8221; (aka the &#8220;cross-loader&#8221;).\u00a0 This DB2 for z\/OS DBA team is top-notch, with centuries of collective experience, but I\u00a0mostly [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,20],"tags":[201,202],"class_list":["post-1052","post","type-post","status-publish","format-standard","hentry","category-db2-for-linux-unix-windows","category-db2-for-zos","tag-cursor-based-load","tag-db2-cross-loader"],"_links":{"self":[{"href":"https:\/\/www.thefillmoregroup.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1052","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thefillmoregroup.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thefillmoregroup.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thefillmoregroup.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thefillmoregroup.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1052"}],"version-history":[{"count":5,"href":"https:\/\/www.thefillmoregroup.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1052\/revisions"}],"predecessor-version":[{"id":1057,"href":"https:\/\/www.thefillmoregroup.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1052\/revisions\/1057"}],"wp:attachment":[{"href":"https:\/\/www.thefillmoregroup.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thefillmoregroup.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thefillmoregroup.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}