[Info-vax] RMS record metadata, was: Re: Re; Spiralog, RMS Journaling (was

lawrencedo99 at gmail.com lawrencedo99 at gmail.com
Thu Jun 23 03:18:02 EDT 2016


On Thursday, June 23, 2016 at 11:40:06 AM UTC+12, Jan-Erik Soderholm wrote:
> You do not need any string handling at all to run SQL databases from Cobol.

Really? I’d be curious as to how you’d handle more dynamic query constructions like (Python code):

    condition = \
        (
            list
                ( # free-text fields
                    "%(name)s like %(value)s"
                %
                    {
                        "name" : field[0],
                        "value" :
                            SQLString("%" + EscapeSQLWild(Params.getvalue(field[1])) + "%"),
                    }
                for field in
                    (
                        ... predefined substring-match fields ...
                    )
                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
                    (
                        ... predefined exact-match fields ...
                    )
                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.getvalue(field[1])),
                            }
                        for op in
                            (
                                ("<", "lt"),
                                ("=", "eq"),
                                (">", "gt"),
                            )
                        if GetCheckbox("%(name)s[%(op)s]" % {"name" : field[1], "op" : op[1]})
                        )
                +
                    ")"
                for field in
                    (
                        ... date fields ...
                    )
                if any
                    (
                        GetCheckbox("%(name)s[%(op)s]" % {"name" : field[1], "op" : op})
                            for op in ("lt", "eq", "gt")
                    )
                )
        )
    if len(condition) != 0 :
        process results of "select «fields» from «table» where" + " and ".join(condition)
        ...
    #end if



More information about the Info-vax mailing list