On Thu, 24 Mar 2011, Graeme Geldenhuys wrote:
> Hi, > [snip] > > How do others handle such database constraints with tiOPF based applications? > Basically I would like to give a more "user friendly" message like "This > record is still in use, so can't be deleted as this time". > > I checked the exception class that was raised, and it is simply > EIBDatabaseError. This doesn't say much about the specific database error > that occurred, plus if we had to use a different persistence layer to > Firebird (eg: PostgreSQL or Oracle), then that exception class would be > different. So how best do we handle this? There is to my knowledge no cross-database way. For firebird, we analyse the error message, find the table name, and then display a nice error to the user. Something like "Cannot delete this item: there is still related information in table XYZ" > > This question relates to any such "foreign key constraint" errors on deleting > data, not just to my School List example. So I don't think it's viable > mentioning that I need to iterate over my data *before* even allowing the > delete to happen. Because that means I would probably pull in millions of > rows of data to do such checks! Yes the School List example might be small, > but other types of data might not. You can do a SELECT COUNT(XYZ) FROM TABLE NNN and then "Cannot delete this item: there are still %d dependent items in table XYZ" we do this sometimes for records where no foreign key is defined (for example when the pointer can point to 2 different kinds of information) Michael. ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ tiOPF-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tiopf-talk
