Database publish child table woes - assistance required

I have a database publishing template, I’ve had to link to the text file because I can’t seem to upload it as an attachment. http://www.appeto.com/template.txt

It has one main table and three children. Version 6.7, and publishing to a DB2 database. As far as I can see all the keys are in place correctly. Indeed the template, when run through publishing, correctly creates the necessary tables. It then correctly publishes data to the tables. Everything looks exactly as it should.

However, after the data is in the database - ie it exists - it will no longer publish those items, coming up with an error “Database item publishing failed. The error was:Cannot process data updates for table (TCMAPPBODYSECTIONS): contains a row that does not have a key value defined for column (page_id).”

I don’t understand this since everything appears correctly in the database. If I can get this answered I might then be able to unpublish data too!

Another funny thing - if I comment out completely the foreign key definitions in the child tables it does then publish successfully - except then it won’t unpublish child rows.

If someone could cast their eyes over my template I’d appreciate it.

Hah - I fixed it. Not sure how but I think it must have been something to do with the database schema. I had a number of templates publishing to the same set of tables, but only one published to all four target tables. I assume my technique of letting the database publishing create the tables itself somehow confused the issue. I deleted all the tables, ran the edition using only the content type/template that used all the tables and voila, after creation, everything works perfectly again.

I am, however, publishing HTML from a child field that uses Editlive. It seems impossible to successfully base64 encode/decode child values when you’re using $rx.asmhelper.childValues()…

Andrew