[Babase] preg upload creates error in cycstats

Karl O. Pinc kop at meme.com
Mon Jan 28 14:16:48 EST 2008


On 01/28/2008 12:53:01 PM, kfenn wrote:
> Hi Karl,
> 
> Well nothing is ever easy, is it?  Step one in this update involves  
> putting a pregnancy in to the system that was missed/leftover from  
> the 06b updata for reasons not worth explaining.  It uploaded with  
> little fuss last time, but now I'm getting a new error message.
> 
> ERROR: update or delete on "cycpoints" violates foreign key  
> constraint "Cpids on CYCPOINTS" on "cycstats" DETAIL: Key  
> (cpid)=(30136) is still referenced from table "cycstats". CONTEXT:  
> SQL statement "DELETE FROM cycpoints WHERE cpid = $1 " PL/pgSQL  
> function "_remove_autom" line 56 at SQL statement SQL statement  
> "SELECT _remove_autom( $1 , $2 , $3 )" PL/pgSQL function  
> "cycpoints_func" line 130 at perform SQL statement "UPDATE cycpoints  
> SET cpid = cpid WHERE cpid = $1 " PL/pgSQL function "pregs_func" line  
> 165 at SQL statement

Crud.  I knew not having cycstats/repstats update automatically was
going to mean headaches, but I hadn't thought of this one.

> 
> I think I understand it: an automatic mdate was already been created  
> for the cycle following the conceptive date for this pregnancy.   
> Because of this mdate, there are also a series of records in the  
> cycstats table.  I can't just make the cycle a conceptive cycles  
> because the cycstats already say it wasn't.

Yes.  I think that's pretty much it.

> 
> I thought I could try a DELETE statement to get rid of the automatic  
> mdate and then let the system regenerate the cycstats for this  
> female, but the system is still complaining about that cycstat table.
> 
> ERROR:  update or delete on "cycpoints" violates foreign key  
> constraint "Cpids on CYCPOINTS" on "cycstats"
> DETAIL:  Key (cpid)=(30136) is still referenced from table "cycstats".
> 
> *In statement:*
> Delete from cycpoints where cpid = 30136;

Deleting the automatic M date won't do any good because the
system will just re-create it anyhow.  And, it'll automatically
go away when it needs to go away.  What's happening here is that
the automatic Mdate is automatically going away, but cycstats
does not want it to go away.

The thing to do is delete the CYCSTATS row that's causing the
problem, fix things, and then rebuild CYCSTATS.  That'd be
how I'd try approaching it.

If you wanted to be brutal, you could delete _all_ the CYCSTATS rows.
Rebuilding will rebuild them anyhow.



> 
> So I'm not sure what to do or why this error is just appearing now.   
> I have a vague recollection that we had not yet generated the new  
> cycstats before in babase _test....so I went looking for info on how  
> I might do that anyhow, but I couldn't find anything about the  
> cycstasts table in the papio index.  Am I blind?  Is there  
> documentation on that table?  How do I fix these errors and do you  
> think I'm likely to see them again as I load more pregs?  I don't  
> really have a handle on how or when cycstats gets updated.

CYCSTATS and REPSTATS are the one part of the system that's not
"automatic".  Programs must be run to manually update them.
These programs need to be run more often than I'd expect that
you expect ;-) because even changes to Statdate can affect
the results and (IIRC) there's a lot of changes that will cause
Statdate to change.

It's hard to find the documentation on the programs in the
docs.  The REPSTATS/CYCSTATS docs are a bit easier to find,
under section "4. Baboon Data: Analyzed", subsection
"The Reproductive State Tables".  (I've thought about various
changes to the amount of detail in the table of contents and
have no good solution.  There's always either too much or
too little.)

The programs are all in section "9. Babase PROGRAMS", subsection
"Useful Programs and Functions".  You either have to hit the
"next" link a lot or look at the entire documentation as one
giant page.

Karl <kop at meme.com>
Free Software:  "You don't pay back, you pay forward."
                  -- Robert A. Heinlein



More information about the Babase mailing list