[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [GNUe] cascade insert into master detail
From: |
Reinhard Mueller |
Subject: |
Re: [GNUe] cascade insert into master detail |
Date: |
Mon, 10 Dec 2007 14:29:12 +0100 |
Hi, Oleg!
Finally I had the time to look into this.
Am Dienstag, den 04.12.2007, 19:17 +0200 schrieb Oleg Noga:
> When i am only inserting new spr_user row it is ok.
> When i am only inserting new spr_usergroup row it is ok.
> When i am trying to insert a user with newly entered group list i have
> exception:
You are using Posgres, which doesn't have OIDs for user tables by
default.
So whenever you insert a new master record, the Postgres server assigns
it a new user_id on its own. The client (gnue-forms) has no way of
finding out what user_id the newly inserted record got. So gnue-forms
also has no way of setting that user_id in the detail records.
If you enable OIDs, Postgres tells gnue-forms about the OID of the newly
inserted record, and gnue-forms can query the record again using that
OID and find out about the user_id assigned.
To enable OIDs, you have to:
1. CREATE TABLE ......... WITH OIDS;
2. have "use_oid = yes" in your connections.conf
I have tried it, and it works if you do it that way.
> What is 'rowid' datasource attribute?
Please forget about that attribute, it will soon be deprecated.
> How datasource behaviour depends on primarykey, primarykeyseq and
> rowid attributes defined or not?
primarykey: will be used to find a record again after it has been
changed. Gnue-forms relies on the assumption that the primary key of a
record never changes through triggers or stored procedures. This concept
fails for newly inserted records if the primary key is set from a
sequence (see above). If a rowid is available, it is preferred over the
primary key, since the rowid is guaranteed to *never* change.
primarykeyseq: name of a sequence. If set, the client (gnue-forms) will
query that sequence from the database and directly set the primary key
of a newly inserted record before posting it. This is a workaround for
exactly your problem, but it is very ugly: it moves stuff to the client
that should happen at the server. I recommend to avoid this at any cost.
Thanks,
Reinhard
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil