Oracle
 sql >> Base de Dados >  >> RDS >> Oracle

verifique se há zero linhas na consulta selecionada


Use a estrutura sqlca
EXEC SQL include "sqlca.h"
#define NO_ROWS_FOUND (sqlca.sqlcode==1403)
EXEC SQL BEGIN DECLARE SECTION;
    int val=0;
    short ind=0;
EXEC SQL END DECLARE SECTION;

EXEC SQL 
    select value
    int :val :ind 
      from mytable where rownum=1;
if(NO_ROWS_FOUND)
   printf("No rows found\n");