{"id":753,"date":"2018-03-20T14:51:02","date_gmt":"2018-03-20T13:51:02","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=753"},"modified":"2018-03-20T14:51:53","modified_gmt":"2018-03-20T13:51:53","slug":"iseries-check-if-table-exists-return-message-in-embedded-statement","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/iseries-check-if-table-exists-return-message-in-embedded-statement\/","title":{"rendered":"iSeries: Check if table exists + return message in embedded statement"},"content":{"rendered":"<pre class=\"lang:default decode:true\">BEGIN ATOMIC\r\n DECLARE @ROWCOUNT INT NOT NULL DEFAULT 0;\r\n SELECT COUNT(*) INTO @ROWCOUNT FROM QSYS2.SYSTABLES WHERE TABLE_NAME = 'View1' and TABLE_SCHEMA = CURRENT_SCHEMA;\r\n IF(NOT @ROWCOUNT &gt; 0) THEN\r\n CREATE OR REPLACE VIEW View1 AS SELECT * FROM Users;\r\n SIGNAL SQLSTATE VALUE '99998' SET MESSAGE_TEXT = 'VIEW View1 CREATED';\r\n ELSE\r\n SIGNAL SQLSTATE VALUE '99999' SET MESSAGE_TEXT = 'VIEW View1 EXISTS'; \r\n END IF;\r\nEND<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>BEGIN ATOMIC DECLARE @ROWCOUNT INT NOT NULL DEFAULT 0; SELECT COUNT(*) INTO @ROWCOUNT FROM QSYS2.SYSTABLES WHERE TABLE_NAME = &#8216;View1&#8217; and TABLE_SCHEMA = CURRENT_SCHEMA; IF(NOT @ROWCOUNT &gt; 0) THEN CREATE OR REPLACE VIEW View1 AS SELECT * FROM Users; SIGNAL SQLSTATE VALUE &#8216;99998&#8217; SET MESSAGE_TEXT = &#8216;VIEW View1 CREATED&#8217;; ELSE SIGNAL SQLSTATE VALUE &#8216;99999&#8217; SET MESSAGE_TEXT [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-753","post","type-post","status-publish","format-standard","hentry","category-other-scripts"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/753","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=753"}],"version-history":[{"count":4,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/753\/revisions"}],"predecessor-version":[{"id":1062,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/753\/revisions\/1062"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=753"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=753"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=753"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}