Oracle
 sql >> Database >  >> RDS >> Oracle

controlla zero righe nella query di selezione

Usa la struttura 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");