Re: Trying to write a prog to load data AND comply w/referentail integrity
Posted in 1995
Topics: Triggers, Constraints & Referential Integrity, Migration, Import/Export & Data Conversion
root@TeamInfinity.com (root) wrote: > > This may sound like a very easy question, so much the easier for you to > answer hopefully... > > We are using informix and powerbuilder. (Just telling you this, we > actually want to just use STANDARD SQL to accomplish this so our platform > should not make a difference) > > We are trying to load data from a migration tablespace into a production > tablespace in such a way that referential integrity is maintained, actually > we have no choice because Constraints restrict adding one record to a file > unless a required record is in another file first. Was thinking to use > cursor, and fetch and insert, but how do we determine if a required record > exists in another table where a referential constraint requires there to be > one, before adding a record to another table. Was thinking of using SQL > count, but how do I take that SQL statements output and use it in a > comparison to see if the record exists or not before adding another record > to another table. I am used to using CLIPPER where you can just do a find() > and if eof() I know it does not exist. If you could give me syntax, we > would greatly appreciate it. There is no such think as STRAIGHT SQL right ? > We have to mix it in with C or COBOL, if so C would be the preferred way, as > I do alot of C programming. Just let the system (the RDBMS) tell you when you fail. If tables are created with constraints and referential integrity, the RDBMS itself tell you what's wrong by naming the faulty constraint. A trick : First fill the entities and then, fill the relations that way, you'll always ensure that, if your data are correct, there will be no problem a load-time. HTH. Alain.