{"id":25608,"date":"2021-03-10T20:45:06","date_gmt":"2021-03-10T13:45:06","guid":{"rendered":"https:\/\/tom.ji42.com\/?p=25608"},"modified":"2021-03-10T20:45:06","modified_gmt":"2021-03-10T13:45:06","slug":"tableupdate-2","status":"publish","type":"post","link":"https:\/\/tom.tomwork.net\/?p=25608","title":{"rendered":"TABLEUPDATE()"},"content":{"rendered":"<h2><span id=\"Purpose\" class=\"mw-headline\">Purpose<\/span><\/h2>\n<p>Function to commit buffered changes<\/p>\n<h2><span id=\"Syntax\" class=\"mw-headline\">Syntax<\/span><\/h2>\n<p>TABLEUPDATE(&lt;expL1&gt; | &lt;expN&gt; [, &lt;expL2&gt; [, &lt;workarea | alias&gt; [, &lt;arrayname&gt;]]])<\/p>\n<h2><span id=\"See_Also\" class=\"mw-headline\">See Also<\/span><\/h2>\n<p><!--more--><\/p>\n<p><a title=\"CURSORGETPROP()\" href=\"https:\/\/www.lianja.com\/doc\/index.php\/CURSORGETPROP()\">CURSORGETPROP()<\/a>,\u00a0<a title=\"CURSORSETPROP()\" href=\"https:\/\/www.lianja.com\/doc\/index.php\/CURSORSETPROP()\">CURSORSETPROP()<\/a>,\u00a0<a title=\"CURVAL()\" href=\"https:\/\/www.lianja.com\/doc\/index.php\/CURVAL()\">CURVAL()<\/a>,\u00a0<a title=\"GETFLDSTATE()\" href=\"https:\/\/www.lianja.com\/doc\/index.php\/GETFLDSTATE()\">GETFLDSTATE()<\/a>,\u00a0<a title=\"OLDVAL()\" href=\"https:\/\/www.lianja.com\/doc\/index.php\/OLDVAL()\">OLDVAL()<\/a>,\u00a0<a title=\"TABLEREVERT()\" href=\"https:\/\/www.lianja.com\/doc\/index.php\/TABLEREVERT()\">TABLEREVERT()<\/a>,\u00a0<a title=\"SETFLDSTATE()\" href=\"https:\/\/www.lianja.com\/doc\/index.php\/SETFLDSTATE()\">SETFLDSTATE()<\/a><\/p>\n<h2><span id=\"Description\" class=\"mw-headline\">Description<\/span><\/h2>\n<p>The TABLEUPDATE() function is used to commit changes during buffered processing. If &lt;expL1&gt; is .T. or &lt;expN&gt; 1 (True) TABLEREVERT() applies to all rows under table buffering and the current row under row buffering. If &lt;expL1&gt; is .F. or &lt;expN&gt; 0 (False) TABLEREVERT() only applies to the current row. If &lt;expN&gt; is 2, updates are processed as if &lt;expN&gt; is 1, but encountering an error does not stop the update. Instead, error information is stored in the array, &lt;arrayname&gt;, if specified. The optional &lt;expL2&gt; determines whether changes made by another user are overwritten (.T.) or not (.F.).<\/p>\n<p>If the optional &lt;workarea | alias&gt; is specified, then the function will operate in the required location.<\/p>\n<h2><span id=\"Example\" class=\"mw-headline\">Example<\/span><\/h2>\n<div class=\"csh\">\n<pre class=\"recital\">close databases\r\nclear\r\nset exclusive off\r\nopen database southwind\r\nuse customers\r\n\/\/ Set to known value before start\r\nreplace customerid with \"ALFKI\"\r\n\u00a0\r\ncursorsetprop(\"Buffering\", 5, \"customers\")\r\nmessagebox(\"Buffering set to \" +etos(cursorgetprop(\"Buffering\")))\r\n\u00a0\r\n? \"Original customerid value: \" + customerid\r\n? \"Curval(): \" + curval(\"customerid\")\r\n? \"Oldval(): \" + oldval(\"customerid\")\r\n? \"Fieldstate at start: \" + getfldstate(\"customerid\")\r\n\u00a0\r\nreplace customerid WITH \"LIANJ\"\r\n\u00a0\r\n\/\/ Alter in another session\r\n\/\/ update southwind!customers set customerid = 'MULTI' where recno() = 1\r\n? \"Someone else just updated the record!\"\r\n? \"New customerid value: \" +  customerid \r\n? \"Curval(): \" + curval(\"customerid\")\r\n? \"Oldval(): \" + oldval(\"customerid\")\r\n? \"Fieldstate after replace: \" + getfldstate(\"customerid\")\r\ntablerevert(.T.)\r\n\u00a0\r\n? \"Reverted customerid value: \" +  customerid\r\n? \"Curval(): \" + curval(\"customerid\")\r\n? \"Oldval(): \" + oldval(\"customerid\")\r\n? \"Fieldstate after revert: \" + getfldstate(\"customerid\")\r\n\u00a0\r\nreplace customerid WITH \"LIANJ\"\r\n? \"New customerid value: \" +  customerid \r\ntableupdate(.T.)\r\n? \"Updated customerid value: \" +  customerid\r\n? \"Curval(): \" + curval(\"customerid\")\r\n? \"Oldval(): \" + oldval(\"customerid\")\r\n? \"Fieldstate after replace and update: \" + getfldstate(\"customerid\")\r\n?<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Purpose Function to commit buffered changes Syntax TABLEUPDATE(&lt;expL1&gt; | &lt;expN&gt; [, &lt;expL2&gt; [, &lt;workarea | alias&gt; [, &lt;arrayname&gt;]]]) See Also<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[13],"tags":[],"class_list":["post-25608","post","type-post","status-publish","format-standard","hentry","category-13"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6cOVM-6F2","_links":{"self":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/25608","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=25608"}],"version-history":[{"count":1,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/25608\/revisions"}],"predecessor-version":[{"id":25609,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/25608\/revisions\/25609"}],"wp:attachment":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=25608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=25608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=25608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}