[Info-vax] Any stronger versions of the LMF planned ?, was: Re: LMF Licence Generator Code
Lawrence D’Oliveiro
lawrencedo99 at gmail.com
Wed Aug 18 04:27:32 EDT 2021
On Sunday, August 15, 2021 at 12:46:16 PM UTC+12, Arne Vajhøj wrote:
>
> In Python something like:
>
> sqlstr = 'SELECT name1,name2 FROM pairs'
> param = []
> if any(activeconditions):
> sqlstr = sqlstr + ' WHERE ' + ' AND '.join(map(lambda item:
> item[0] + '=?', activeconditions))
> param = list(map(lambda item: item[1], activeconditions))
> c.execute(sqlstr, param)
> Single static SQL using the coalesce trick and sending over NULL
> for not used parameters means to use a fixed SQL string like:
>
> ... WHERE field1 = COLALESCE(?,field2) AND field2 = COLALESCE(?,field2) ...
>
> and send over values for all fields but NULL for those fields not to be
> used.
>
> In Python something like:
>
> sqlstr = 'SELECT name1,name2 FROM pairs WHERE name1 =
> COALESCE(?,name1) AND name2 = COALESCE(?,name2)'
> allfields = ['name1', 'name2']
> param = []
> for f in allfields:
> param.append(conditions[f])
> c.execute(sqlstr, param)
>
> In VMS COBOL something like:
>
> 01 NAME1 PIC X(32).
> 01 NAME2 PIC X(32).
> 01 NAME1PRES PIC S9.
> 01 FINDNAME1 PIC X(32).
> 01 NAME2PRES PIC S9.
> 01 FINDNAME2 PIC X(32).
> EXEC SQL DECLARE curs CURSOR FOR SELECT name1,name2 FROM pairs WHERE
> name1 = COALESCE(:findname1:name1pres,name1) AND name2 =
> COALESCE(:findname2:name2pres,name2) END-EXEC.
> ...
> EXEC SQL OPEN curs END-EXEC
> ...
> EXEC SQL CLOSE curs END-EXEC.
At least you get points for trying. Notice your code is already about an order of magnitude larger than mine, and liable to increase even more. Consider how you would add another search field: you have to add it in 3 places in the Python version, and is it actually 6 places in the COBOL one?!?
Remember Fred Brooks’ dictum about “10 lines of code per day”? No wonder COBOL programmers have such low productivity ...
More information about the Info-vax
mailing list