Subject Re: PK field that auto filled with wrong generator value
Author cipto_kh
I added more information of that problem:

That TIBOQuery is as a detail and I give a name qrTbBeliD. And I also put another TIBOQuery as master with the name qrTbBeliM. The datasource property of qrTbBeliD is assign to TDataSource component of qrTbBeliM.

The SQL of qrTbBeliM is:
select m."id", m."idTbRekan", m."tahun", m."bulan",
m."kode", m."tanggal", m."keterangan",
m."subTotal", m."disc", m."potongan", m."isPPN", m."ppn", m."biayaLain", m."isCash", m."total",
m."ongkosKirim", m."totQtyBrg",
m."userChanged", m."dateChanged",
r."kode" kode_rekan, r."nama" nama_rekan, r."alamat" alamat_rekan
from "tbBeliM" m
join "tbRekan" r on r."id"=m."idTbRekan"
where m."id" like :id
and m."tanggal" between :tgl1 and :tgl2
order by m."kode"


The SQL of qrTbBeliD is:
select d."id", d."idTbBeliM", d."idTbBarang", d."idTbGudang",
d."qty", d."satuan", d."konversi", d."qtyKecil",
d."hargaSat", d."disc", d."subTotal", d."ongkosKirim",
b."kode", b."nama", b."partNumber", b."satKecil"
from "tbBeliD" d
join "tbBarang" b on b."id"=d."idTbBarang"
where d."idTbBeliM"=:"id"
order by d."id"

And after I inspect more, the value that automatically filled by TIBOQuery on field d."id" of qrTbBeliD is came from m."id" of qrTbBeliM.

Strange for me because if it's as design, then TIBOQuery must clever enough that the relation between the master and the detail is:
where d."idTbBeliM"=:"id"

Which mean the "id" field from qrTbBeliM is filling the d."idTbBeliM" field of qrTbBeliD. Or because the m."id" field of qrTbBeliM and d."id" field of qrTbBeliD that make TIBOQuery automatically match them?

TIA

--- In IBObjects@yahoogroups.com, "Cipto" <cipto.milis@...> wrote:
>
> Hi all,
>
> I use IBO 4.9.14 46 with Firebird 2.1.4
>
> I have TIBOQuery which property IB_Connection set to TIBO_Database and property IB_Transaction set to TIBO_Transaction.
> The transaction component used tiCommitted with AutoCommit set to false and AutoCommitRetains set to false.
>
> The query from TIBOQuery is like this:
> select d."id", d."idTbBeliM", d."idTbBarang", d."idTbGudang",
> d."qty", d."satuan", d."konversi", d."qtyKecil",
> d."hargaSat", d."disc", d."subTotal", d."ongkosKirim",
> b."kode", b."nama", b."partNumber", b."satKecil"
> from "tbBeliD" d
> join "tbBarang" b on b."id"=d."idTbBarang"
> where d."idTbBeliM"=:"id"
> order by d."id"
>
>
> The d."id" (BIGINT) field is a PK on "tbBeliD" table. I use UpdateSQL that generated automatically by TIBOQuery to make this TIBOQuery an updateable query. The update only for "tbBeliD" table.
>
> I also have a generator called "genTbBeliD".
>
> Now the problem is:
> Everytime I insert a new record on "tbBeliD" (just still in insert condition, before post) why the field d."id" is automatically filled with an integer value that I don't know where it come from??
>
> I'm not set any propoerty of TIBO_Query or TIBO_Database to automatically fill the "id" field from any generator, because I explicitly fill d."id" value onBeforePost of TIBO_Query with this statement:
> if qrTbBeliDid.IsNull then
> qrTbBeliDid.AsLargeInt:=conIBO.Gen_ID('"genTbBeliD"', 1);
>
> Any clue??
>
> TIA
>
> [Non-text portions of this message have been removed]
>