0

I'm trying to write a program with C and ESQL. One of the things I want to do is delete old row from one of my table (by comparing with SYSDATE) each time the program is run.

So my SQL code looks like this:

DELETE FROM Trip
WHERE dateT < (SYSDATE - 1);

Now I know this works because I tested it with SQL+ Worksheet

But when I want to do it with ESQL like this:

void deleteOutDated(){
    EXEC SQL DELETE FROM Trip WHERE dateT < (SYSDATE - 1);
    printf("Old trips deletes");
}

My program just freezes there.

So I wanted to know if it is possible to make such a statement in ESQL and if it is what am I doing wrong?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
flatzo
  • 133
  • 1
  • 9
  • Add a newline to the end of the `printf()` statement and try again. Add a `fflush(stdout);` after the `printf()` statement and try again. Presumably, you have a print operation just before this. Superficially, there is no reason for the ESQL not to work. – Jonathan Leffler Aug 07 '11 at 21:14
  • This is not the problem as the rows are not even deleted from the database. Even if removing the printf, problem persists. – flatzo Aug 11 '11 at 03:13
  • So, you have concrete proof that the statement is being executed, but the statement is not completing in a timely manner (appears to hang). Can you detect any activity in the DBMS when it is running? Have you tried using one of the 'explain' mechanisms? Have you tried using a host variable in place of the expression '`(SYSDATE - 1)`' to see whether that makes any difference? How big is the table `Trip`? How long does it take to execute `DELETE FROM Trip; ROLLBACK;`? Have you run table integrity checks on `Trip`? – Jonathan Leffler Aug 11 '11 at 06:30
  • It appears that it was hanging because it was looking for the errorLabel wich doesn't exist in the function. Adding it, the delete worked 2 times, randomly without changing anything. For the activity, I don't know if I can do that as I'm working on the university's database and have limited acces. Haven't try the explain. With an expression as idTrip = 1234 works the same way. The table is about 30 rows. I'm out of town now so I can't execute the rollback. How can I run the integrity check ? (Could their really be an integrity problem with about 30 rows ?) – flatzo Aug 12 '11 at 01:55

0 Answers0