{"id":1319,"date":"2012-05-10T17:37:52","date_gmt":"2012-05-10T22:37:52","guid":{"rendered":"http:\/\/anvil-of-time.com\/wordpress\/?p=1319"},"modified":"2021-03-11T11:24:31","modified_gmt":"2021-03-11T16:24:31","slug":"powerbuilder-discarding-rows-with-find","status":"publish","type":"post","link":"https:\/\/anvil-of-time.com\/powerbuilder\/powerbuilder-discarding-rows-with-find\/","title":{"rendered":"PowerBuilder &#8211; Discarding Rows with Find"},"content":{"rendered":"<p>It&#8217;s a fairly common practice to report on a set of data derived from a larger group of rows. There are many techniques to do this in code and with the methods available with datawindows\/datastores. One typical approach is to use the Filter method. The problem with this is it requires another trip to the database to get the matching rows. Here is a technique to quickly eliminate rows from a datawindow without filtering.<\/p>\n<pre name=\"code\" class=\"VB\">IF ll_part_id &gt; 0 THEN\n  ll_find_row = dw_part.find(&#039;part_id = &#039; + string(ll_part_id), 1, 999999) \/\/&#039;top to bottom&#039;\n    IF ll_find_row &gt; 1 THEN \/\/ if data starts in first row, do nothing\n      dw_part.rowsdiscard( 1, ll_find_row - 1, Primary!)\n    END IF\n    IF dw_part.rowcount() &gt; 0 THEN\n      ll_find_row = dw_part.find(&#039;part_id = &#039; + string(ll_part_id), 999999, 1) \/\/&#039;bottom to top&#039;\n      IF ll_find_row &gt; 0 AND ll_find_row &lt; dw_part.rowcount() THEN\n        dw_part.rowsdiscard( ll_find_row + 1, dw_part.rowcount(), Primary!)\n      END IF\n    END IF\nEND IF<\/pre>\n<p>So what I&#8217;m doing is finding from the beginning of the row set in the Datawindow until I find the first row of what I want then discard all the unwanted rows. Then I use a Find again but this time starting from the <strong>end of the row set<\/strong> and then discard any rows after my desired data.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s a fairly common practice to report on a set of data derived from a larger group of rows. There are many techniques to do this in code and with the methods available with datawindows\/datastores. One typical approach is to use the Filter method. The problem with this is it requires another trip to the&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,10],"tags":[21,12,16],"_links":{"self":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/1319"}],"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=1319"}],"version-history":[{"count":5,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/1319\/revisions"}],"predecessor-version":[{"id":2030,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/1319\/revisions\/2030"}],"wp:attachment":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/media?parent=1319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/categories?post=1319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/tags?post=1319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}