Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.os.vms    |    DEC's VAX* line of computers & VMS.    |    264,096 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 262,850 of 264,096    |
|    Lawrence D'Oliveiro to All    |
|    Re: VMS x86-64 database server    |
|    11 Jul 25 00:33:45    |
   
   From: ldo@nz.invalid   
      
   On Thu, 10 Jul 2025 01:33:08 -0000 (UTC), I wrote:   
      
   > Is it bad to offer users dynamic query capabilities?   
   >   
   > Here’s some code I wrote back in Python-2 days (MySQL-specific):   
   >   
   > # collect list of items matching specified search criteria   
   > condition = \   
   > (   
   > list   
   > ( # free-text fields   
   > "%(name)s like %(value)s"   
   > %   
   > {   
   > "name" : field[0],   
   > "value" :   
   > SQLString("%" + EscapeSQLWild(Para   
   s.getvalue(field[1])) + "%"),   
   > }   
   > for field in   
   > (   
   > ("make", "search_make"),   
   > ("model", "search_model"),   
   > ("details", "search_details"),   
   > ("serial_nr", "search_serial"),   
   > ("inventory_nr", "search_invent"),   
   > )   
   > if Params.getvalue(field[1]) != ""   
   > )   
   > +   
   > list   
   > ( # exact-match fields   
   > "%(name)s = %(value)s"   
   > %   
   > {   
   > "name" : field[0],   
   > "value" : SQLString(Params.getvalue(field[1])),   
   > }   
   > for field in   
   > (   
   > ("class_name", "search_class"),   
   > ("allocation", "search_allocated"),   
   > ("location_name", "search_location"),   
   > )   
   > if Params.getvalue(field[1]) != ""   
   > )   
   > +   
   > list   
   > ( # date fields   
   > "("   
   > +   
   > " or ".join   
   > (   
   > "%(name)s %(op)s %(value)s"   
   > %   
   > {   
   > "name" : field[0],   
   > "op" : op[0],   
   > "value" : SQLString(Params.get   
   alue(field[1])),   
   > }   
   > for op in   
   > (   
   > ("<", "lt"),   
   > ("=", "eq"),   
   > (">", "gt"),   
   > )   
   > if GetCheckbox("%(name)s[%(op)s]" % {"name" :   
   field[1], "op" : op[1]})   
   > )   
   > +   
   > ")"   
   > for field in   
   > (   
   > ("when_purchased", "search_when_purchased"),   
   > ("warranty_expiry", "search_warranty_expiry"),   
   > )   
   > if reduce   
   > (   
   > operator.__or__,   
   > (   
   > GetCheckbox("%(name)s[%(op)s]" % {"name" :   
   field[1], "op" : op})   
   > for op in ("lt", "eq", "gt")   
   > )   
   > )   
   > )   
   > )   
   > condition = " and ".join(condition)   
   >   
   > used as   
   >   
   > select «fields» from «table» where «condition»   
   >   
   > Let’s see your EXEC SQL cope with that ...   
      
   ... still waiting ...   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca