{"id":45201,"date":"2015-07-07T07:00:00","date_gmt":"2015-07-07T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20150707-00\/?p=45201\/"},"modified":"2019-03-13T12:17:06","modified_gmt":"2019-03-13T19:17:06","slug":"20150707-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20150707-00\/?p=45201","title":{"rendered":"Intentionally making the suggestion look nothing like any scripting language, yet understandable enough to get the point across"},"content":{"rendered":"<p>In an internal peer-to-peer discussion list for an internal tool I&#8217;ll call <i>Program&nbsp;Q<\/i>, somebody asked, <\/p>\n<blockquote CLASS=\"q\">\n<p>How can I query the number of free frobs in every table in my table repository? <\/p>\n<\/blockquote>\n<p>I suggested that they could use the command <\/p>\n<pre>\nq query-property \"*::frobs-free\"\n<\/pre>\n<p>taking advantage of the fact that in Program&nbsp;Q, you can specify a wildcard for the table name to query across all tables. <\/p>\n<blockquote CLASS=\"q\">\n<p>Thanks, this looks promising, but my repository has a huge number of tables, so the <code>q query-property<\/code> command refuses to expand the <code>*<\/code> wildcard that much. I can get around this by issuing 26 queries, one for each letter of the alphabet: <\/p>\n<pre>\nq query-property \"a*::frobs-free\"\nq query-property \"b*::frobs-free\"\nq query-property \"c*::frobs-free\"\n...\nq query-property \"z*::frobs-free\"\n<\/pre>\n<p>Is there a better way to do this? <\/p>\n<\/blockquote>\n<p>I replied with some pseudocode. <\/p>\n<pre>\n(\n  from table in `q list-tables`\n  select table + \"::frobs-free\"\n) | q query-property @-\n<\/pre>\n<p>(The <code>@<\/code> means that it should take the list of properties from a file, and we give <code>-<\/code> as the file name, meaning standard input. Not that it&#8217;s important because <i>I completely made this up<\/i>.) <\/p>\n<p>A colleague of mine noted that I provided just enough syntax to explain the algorithm clearly, but in a form that cannot be executed in any scripting language, so the user understands that it is just an algorithm that needs to be massaged into something that will actually run. <\/p>\n<p>It&#8217;s a neat trick when it works. <a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2009\/04\/16\/9551818.aspx\">But when it fails, it fails spectacularly<\/a>. Fortunately, in this case, it worked. <\/p>\n<p><b>Bonus chatter<\/b>: For all I know, that&#8217;s valid PowerShell. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pseudobabble.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-45201","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>Pseudobabble.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/45201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=45201"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/45201\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=45201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=45201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=45201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}