New topic: Can't insert record in child table due to constraints?
<http://forums.realsoftware.com/viewtopic.php?t=44818> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message DonGeraldo Post subject: Can't insert record in child table due to constraints?Posted: Mon Jul 23, 2012 11:20 pm Joined: Tue Jan 17, 2006 9:08 pm Posts: 49 Location: San Jose, CA I'm a noob and have an issue with a new project I'm working on. I have searched the forums here and haven't found the answer I needed to solve this problem. I have two tables: albums (which contains an auto-increment field called "id") album_songs (which contains a foreign key field called "Album_FK", related to "id" in the parent table albums) When I try to save the child record, I get: Database Error: 1452 Cannot add or update a child row: a foreign key constraint fails (`bgr`.`album_songs`, CONSTRAINT `Album_FK` FOREIGN KEY (`Album_FK`) REFERENCES `albums` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) I've tried changing the CASCADE on/off but no difference. I'm first saving the parent record, then saving the child records using a child foreign key: rec.IntegerColumn("Album_FK") = Session.db.GetInsertID() The data is correct in the debugger, so I'm just not sure what's wrong here. Any help would be greatly appreciated!! Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
