{"id":171,"date":"2009-04-12T09:31:22","date_gmt":"2009-04-12T03:31:22","guid":{"rendered":"http:\/\/techsatwork.com\/blog\/?p=171"},"modified":"2016-01-07T11:31:13","modified_gmt":"2016-01-07T05:31:13","slug":"db2-command-line-processing","status":"publish","type":"post","link":"https:\/\/techsatwork.com\/?p=171","title":{"rendered":"DB2 Command Line Processing"},"content":{"rendered":"<p>Yesterday, \u00c2\u00a0I had posted about db2batch. One of my blog reader who was pretty new DB2 asked me how to run a set of sql from a file. Thats when I realized my blog doesn&#8217;t cover newbies, so thought I will write this up&#8230;<br \/>\nDB2 has a command line interface or can use the db2 command editor which is a GUI based. \u00c2\u00a0I like command line, so here is how you can do it.<\/p>\n<ul> In Windows :<\/ul>\n<p>From the Run prompt, type db2cmd and hit enter<br \/>\nNow you should have a command window with the title DB2 CLP, but still give you a drive letter prompt.<\/p>\n<ul> In Unix\/Linux\/Mac:<\/ul>\n<p>Start a terminal session, make sure you have executed the db2profile to have the db2 environment setup for your userid. If you are not sure, then execute this  .\/sqllib\/db2profile . This would set the environment up.<\/p>\n<p>For ease of illustration here is an example :<\/p>\n<p>This screen shot shows execution of a file that contains one sql<\/p>\n<p><a href=\"https:\/\/techsatwork.com\/blog\/wp-content\/uploads\/2009\/04\/picture-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-176 alignleft\" title=\"picture-1\" src=\"https:\/\/techsatwork.com\/blog\/wp-content\/uploads\/2009\/04\/picture-1-300x209.png\" alt=\"picture-1\" width=\"270\" height=\"188\" srcset=\"https:\/\/techsatwork.com\/wp-content\/uploads\/2009\/04\/picture-1-300x209.png 300w, https:\/\/techsatwork.com\/wp-content\/uploads\/2009\/04\/picture-1.png 668w\" sizes=\"auto, (max-width: 270px) 100vw, 270px\" \/><\/a><\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>This screenshot shows execution of a with\u00c2\u00a0multiple\u00c2\u00a0sql\u00c2\u00a0<\/p>\n<p><a href=\"https:\/\/techsatwork.com\/blog\/wp-content\/uploads\/2009\/04\/picture-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-medium wp-image-180\" title=\"picture-2\" src=\"https:\/\/techsatwork.com\/blog\/wp-content\/uploads\/2009\/04\/picture-2-300x234.png\" alt=\"picture-2\" width=\"300\" height=\"234\" srcset=\"https:\/\/techsatwork.com\/wp-content\/uploads\/2009\/04\/picture-2-300x234.png 300w, https:\/\/techsatwork.com\/wp-content\/uploads\/2009\/04\/picture-2.png 664w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>This screenshot illustrates how to turn off auto commit and how to rollback an sql\u00c2\u00a0<\/p>\n<p><a href=\"https:\/\/techsatwork.com\/blog\/wp-content\/uploads\/2009\/04\/picture-31.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-medium wp-image-181\" title=\"picture-31\" src=\"https:\/\/techsatwork.com\/blog\/wp-content\/uploads\/2009\/04\/picture-31-249x300.png\" alt=\"picture-31\" width=\"249\" height=\"300\" srcset=\"https:\/\/techsatwork.com\/wp-content\/uploads\/2009\/04\/picture-31-249x300.png 249w, https:\/\/techsatwork.com\/wp-content\/uploads\/2009\/04\/picture-31.png 664w\" sizes=\"auto, (max-width: 249px) 100vw, 249px\" \/><\/a><\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>\u00c2\u00a0<\/p>\n<p>If you omit the &#8216;s&#8217; from the &#8216;-svtf &#8216; , db2 will process the rest of the sql in a file even if one of the sqls error out. \u00c2\u00a0In other words, &#8216;-s&#8217; stops execution of sqls in a file when db2 encounters an error in the execution.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday, \u00c2\u00a0I had posted about db2batch. One of my blog reader who was pretty new DB2 asked me how to run a set of sql from a file. Thats when I realized my blog doesn&#8217;t cover newbies, so thought I will write this up&#8230; DB2 has a command line interface or can use the db2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","site-transparent-header":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[3],"tags":[80,83,79,943,78,84,81,82,8],"class_list":["post-171","post","type-post","status-publish","format-standard","hentry","category-db2","tag-svtf","tag-command-editor","tag-command-line","tag-db2","tag-db2-clp","tag-db2-command","tag-db2cmd","tag-db2profile","tag-sql"],"_links":{"self":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts\/171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=171"}],"version-history":[{"count":10,"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts\/171\/revisions"}],"predecessor-version":[{"id":185,"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts\/171\/revisions\/185"}],"wp:attachment":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}