gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnumed-devel] re: problems


From: syan tan
Subject: [Gnumed-devel] re: problems
Date: Sat, 22 Nov 2003 20:25:18 +1100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030313

def setActiveName (self, firstnames, lastnames): def setActiveName (self, firstnames, lastnames): cmd = "update v_basic_person set firstnames = %s, lastnames = %s where i_id = %s" cmd = "update names set active = true, firstnames = %s, lastnames = %s where id_identity = %s" return gmPG.run_commit ('personalia', [(cmd, [firstnames, lastnames, self.ID])]) return gmPG.run_commit ('personalia', [(cmd, [firstnames, lastnames, self.ID])]) #--------------------------------------------------------- #--------------------------------------------------------- def getTitle(self): def getTitle(self): *Line 174* *Line 174* return data[0][0] return data[0][0] #-------------------------------------------------------- #-------------------------------------------------------- def setTitle (self, title): def setTitle (self, title): cmd = "update v_basic_person set title = %s where i_id = %s" cmd = "update names set title = %s where id_identity = %s" return gmPG.run_commit ('personalia', [(cmd, [title, self.ID])]) return gmPG.run_commit ('personalia', [(cmd, [title, self.ID])]) #--------------------------------------------------------


When I do the save, the name is reverted back to --?--, --?--
I think this occurs because "update names ..." won't work because there isn't a dummy name row, referencing the dummy identity, as create_identity doesn't create one.

Even if you change it into a insert statement , the names will end up with active = 'f' because the update to names is broken up into 2 updates.
The first update is with setActiveNames()  will set active = true.
The second update from setTitle () will fire the trigger for names which sets any
previous row referencing the same identity to active = false, before
updating the now inactive row with a a title.

I 've tried this about 5 times each day on 3 separate days ( before I changed
create_identiy insert v_basic_person,  after  it was changed back,
after the change to setActiveName and setTitle as update into names) .

I can't explain why setTitle will work , when the dummy identity is created with
an insert into v_basic_person.

Looking in gmDemographic-Person_views.sql
the FUNCTION F_activate_name() will check for a NEW.active update, and
will set all previous rows pointiing to the same identity active='f'

What I think makes the update v_basic_person and insert into v_basic_person work, is that update seems to have the behaviour of copying the old.lastnames and old.firstnames into the do instead insert into names , so one
can supply a new.Title without supplyin a new.lastnames and new.firstnames.
Therefore doing update v_basic_person set title = 'newTitle' ....
will not lose the old first and last name values, because these are copied over
by the trigger.



















reply via email to

[Prev in Thread] Current Thread [Next in Thread]