Re: Testing for no input with CONSTRUCT statement
Posted in 1994
Topics: SQL Development & Query Writing
In article <1994Jan28.201140.15960@fripp.ri.cadre.com>, Joe Hartley <jh@cadre.com> wrote: >I had a situation where I wanted to prevent the users of a query screen from >simply hitting the escape key and selecting every row in a table. My >problem was that we are using the CONSTRUCT statement to generate the WHERE >clause of the SELECT statement. After many gyrations, I finally discovered >that in such a situation, the CONSTRUCT statement builds its where clause >simply as "1=1", which of course, simply evaluates to TRUE. Unfortunately, >it buries this in a string surrounded by newlines and spaces. Perhaps there is a difference between versions (I hate to think of how many programs will break if this is true!) but with 4.1 SE we are able to do the following: DEFINE null_construct CHAR(4) DEFINE const_text CHAR(2000) LET null_construct = " 1=1" CONSTRUCT const_text ON tab1.* FROM screen_rec.* IF const_text = null_construct THEN ... ELSE ... END IF The key is putting the space before the 1=1. -Todd ... stuff deleted ... >--- >============================================================================= >Joe Hartley | jh@cadre.com - Whenever you find that you are on the >Cadre Technologies | side of the majority, it is time to reform. - M. Twain >222 Richmond St. | ------------------------------------------------------ >Providence, RI 02903 | Overman 1st Class - the Kilgore Trout Memorial Clench >(401) 351-5950 x266 | of the Church of the SubGenius >============================================================================= _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ = Todd A. Bernhardt Wheaton College = = bernha@david.wheaton.edu (708) 752-5232 = -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- | Theory like mist on eye glases. Obscure facts. | | -Charile Chan | \\_____________________________________________________________________/