[Info-vax] Better languages than BASIC

Lawrence D'Oliveiro ldo at nz.invalid
Fri Jan 12 15:38:42 EST 2024


On Fri, 12 Jan 2024 15:04:34 -0500, Dave Froble wrote:

> SQL is nice.  It works.  But, I consider it a square hole, and you
> better not have a round peg.
> 
> For some operations, one must go through rather convoluted things to get
> the desired result.

Would some other language make things easier? Is this your idea of
“rather convoluted things”? It can display entries for all clients or
just a single specified client, and it can display only charged
entries, only uncharged entries, or both:

    for entry in get_each_record \
      (
        table_name =
            "clients inner join jobs on clients.client_id = jobs.client_id"
            " inner join hours on jobs.job_id = hours.job_id",
        fields =
            [
                "clients.client_id as client_id",
                "jobs.job_id as job_id",
                "clients.name as client_name",
                "jobs.description as description",
                "hours.from_time as from_time",
                "hours.to_time as to_time",
                "hours.notes as notes",
            ],
        condition =
            " and ".join
              (
                    (
                        lambda : (),
                        lambda : ("clients.client_id = %u" % only_client,),
                    )[only_client != None]()
                +
                    (
                        lambda : (),
                        lambda :
                            (
                                "hours.invoice_entry_id %s null"
                            %
                                (
                                    "is",
                                    "is not",
                                )[charged],
                            ),
                    )[charged != None]()
                +
                    (
                        "hours.from_time >= %u" % day_local_start(when_worked),
                        "hours.from_time < %u" % day_local_start(when_worked + 1),
                        "hours.to_time is not null",
                    )
              ),
        extra = "order by hours.from_time, clients.name, jobs.description"
      ) \
    :
        ... process entry ...
    #end for



More information about the Info-vax mailing list