{"id":277,"date":"2010-08-10T20:20:17","date_gmt":"2010-08-11T01:20:17","guid":{"rendered":"http:\/\/anvil-of-time.com\/wordpress\/?p=277"},"modified":"2021-03-09T07:34:55","modified_gmt":"2021-03-09T12:34:55","slug":"powerbuilder-gotcha-sql-errors","status":"publish","type":"post","link":"https:\/\/anvil-of-time.com\/powerbuilder\/powerbuilder-gotcha-sql-errors\/","title":{"rendered":"PowerBuilder &#8216;Gotcha&#8217; &#8211; SQL Errors"},"content":{"rendered":"<p>Most applications I&#8217;ve worked on make at least a limited attempt to inform the user of any database related errors especially after an insert, update, and (usually) a commit. Along with this is normally code which displays the database error from the transaction object in a messagebox. Unless you use a custom messagebox with a timer you have to account for the user who presses save while walking away to go to lunch and thereby messes up who knows what.<\/p>\n<p>Generally the flow is: Execute the SQL, check for an error, show error, rollback the transaction.<\/p>\n<p>Sample<\/p>\n<pre name=\"code\" class=\"VB\">update PartMaster\nset stockDtm = :ldt_pro_start\nwhere PartMaster.partNo = :ll_part_id ;\n\nIF sqlca.sqlcode &lt;&gt; 0 THEN\n\tRollback USING SQLCA; \/\/ lost the error text from the update...\n\tMessagebox(this.title, &quot;SQL error: &quot; + SQLCA.sqlerrtext ,StopSign!)\n\t\/\/ and so on\nEND IF<\/pre>\n<p>This code will only show the error if the rollback failed. To show the &#8216;real&#8217; error you need to assign the sqlerrtext to a string variable prior to issuing any further SQL commands.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most applications I&#8217;ve worked on make at least a limited attempt to inform the user of any database related errors especially after an insert, update, and (usually) a commit. Along with this is normally code which displays the database error from the transaction object in a messagebox. Unless you use a custom messagebox with a&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,10],"tags":[12,16],"_links":{"self":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/277"}],"collection":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/comments?post=277"}],"version-history":[{"count":6,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/277\/revisions"}],"predecessor-version":[{"id":1789,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/277\/revisions\/1789"}],"wp:attachment":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/media?parent=277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/categories?post=277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/tags?post=277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}