Subject Re: order by on different way
From Mervyn Bick <invalid@invalid.invalid>
Date Sat, 20 Nov 2021 12:27:33 +0200
Newsgroups dbase.getting-started

On 2021/11/19 21:51, Dirk wrote:

>   Mervyn
>
>    thanks for your comphrensive analyse
>
>     i just wondering using the mastersource
>
>      i you have another form to add and modify contact as mentioned
>
>      this.VRAAGBAK_CONTACT = new QUERY(this)
>     with (this.VRAAGBAK_CONTACT)
>        left = 112.0
>        top = 88.0
>        width = 99.0
>        height = 37.0
>        database = form.databank_gegevklant
>        sql = [Select c.idnummer, c.name, c.voornaam, c.task, c.telefon,
> c.fax, c.gsm, c.email, c.verlaten, c.info;
>                    from "communicate" c where idnummer = :idnummer]
>        params["idnummer"] = ""
>        masterSource = form.vraagbak_firmas.rowset
>        active = true
>     endwith
>

It seems unusual to have two child queries with common fields but it
shouldn't cause problems.  Be aware though that a record added via one
child rowset won't automatically be available to the other child rowset
until the user navigates the parent rowset.


If all the fields are from the same table and you list them individually
you don't need to use a table correlation name (alias) to identify which
table the fields belong. This would apply even if you add a calculated
field as in vraagbak_kontakt.

    sql= [select idnummer, name, voornaam, voornaam||' '||name as
Voor_en_Naam, task, telefon, fax, gsm, email, verlaten, info from
communicate where idnummer = :idnummer]

You would, however, need the table correlation name if you use the *
wildcard to select all the fields and then add a calculated field.

     sql = [select c.*, voornaam||' '||name as Voor_en_naam from
communicate c where idnummer = :idnummer]


>
>     i use the save()
>      form.vraagbak_contact.rowset.fields["idnummer"].value =
> form.vraagbak_firmas.rowset.fields["idnummer"].value
>
>      using the masterfield and masterrowset
>
>
>       a form.vraagbak_contact.rowset.save() is sufficient


I haven't used masterfields/masterrowset to link a child to a parent for
many years in my own code but I can't recall ever coming across this
"shortcut".  (Probably because I would explicitly place a value in the
idnummer field without thinking anyway. :-) )

Internally mastersource works quite differently and the programmer
obviously didn't consider it necessary to add the "shortcut".  Idnummer
in the child table can't be an autoinc field so one shouldn't really
expect dBASE to supply a value for the field when a record is added.

Although dBASE will apparently supply the idnummer for a new child
record where masterfields/masterrowset is used to link tables,
explicitly assigning a value as you have done for the mastersource
version shouldn't cause any problems.

Mervyn.