cembedded-sql

embedded sql in c,how to check if records exist


I have tried these:

1.if (EXEC SQL EXIST SELECT ...)
2.EXEC SQL IF EXIST SELECT ...

but none of these work,any help?


Solution

  • Select the count and check whether it is zero. Something along this line:

    int a;
    EXEC SQL SELECT count(*) INTO :a
             FROM some_table
             WHERE some_condition;
    if (a != 0)...