Re: ESQL/C, Duplication Check & Error -407
Posted in 1993
In article <1tasv8INNmi0@emory.mathcs.emory.edu>, obelix.informix.com!johnl@emory.mathcs.emory.edu (Jonathan Leffler) writes: > (..original post deleted..) > >I've not seen any responses, possibly because it isn't entirely clear from >the question where the data is being sourced from, but here goes anyway. >I'm not clear whether you are using the ISQL for anything -- you ESQL/C >program would not normally need anything from there. I'm assuming it is >not relevant to this particular problem. > >If the data is coming from some external source like a set of ASCII files, >the best way to eliminate the duplicate data is probably by using the Unix >sort program to eliminate the duplicates. With careful use, you can tell >it exactly which fields to sort on, and so on. You can also use awk, sed >and uniq to help identify where the problems are. Incidentally, if your >data is coming from an unreliable source, is delimited, and you are running >into problems with some rows not containing enough fields, you can use the >script below to identify where the trouble is > (..rest of the article deleted..) First thanks Jonathan for your exhaustive response. Maybe I should have mentioned in my first post on this subject that one of the columns in the table is of type "datetime," which in turn is represented in ESQL/C as a dtime data structure. And that appears to be the cause of the problem. Because it's not quite clear what exactly the following means: /* declare datetime variable */ $datetime year to minute my_date_time char *str = "1993-05-19 12:00" dtcvasc(str, &my_date_time); $SELECT FROM MY_TABLE WHERE date_time_field = :my_date_time; Since my_date_time is not "atomic," how to compare one data structure with another? Admittedly it works for a while then it will choke. I did try the alternative: $SELECT FROM MY_TABLE WHERE date_time_field = :str; No luck there either. This is my solution: select all the date_time_field values with a cursor, fetch a value, convert the vale into a character string using dttoasc, then use the c function strcmp to determine whether there is a duplication or not. Cumbersome, but it works. Comments are welcome. With Regards, Pei-yu Huang