Re: Sample code to update database needed
Posted in 1996
Assuming that you are only refering to the unique keys in table_a and table_b when you check for "if in the table" condition, and seeing that the main_table can not have such indices - Why not try and insert into all 3 tables? If the errors are ignored in the esql/c code, the duplicates will simply not make it into the tables. This might be slightly more costly compared to selects, but I have used it in the past for some Q&D loads. HTH -- Dave Wagle wrote: > > Help! > > I have a need to check an ascii input file against several tables, > if the entries are not in the tables, I need to insert them, then > move on to the next (fixed length) record in the ascii table. > > I am using ESQL/C version 7.11, SE 7.11, and I-SQL 6.02 on a sparc > station 2 running solaris 2.5. > > Basically, a simplified version of the database is like this: > > Table_a > > code char(5); > value char(25); > > Table_b > > code char(5); > value char(25); > > Main_Table > > a_code char(5) references table_a.code; > b_code char(5) references table_b.code; > mainvalue1 ... > mainvalue2 ... > > etc. > > I want to insert values from teh ascii tables only if they do not already > exist in table_a or table_b respectfully, and to always insert into the > main_table all the values. > > Can anyone send me some sample code to do this? > > Thanks!! > > Dave > > David Wagle -- dave@aries.uthscsa.edu > finger me for more info > > /\\~~~/\\ > > < > > ^ ^ < "For God so loved the world that he gave us samoyeds." > > (_o_) < > U