how to check if an row exists in pro-c / oracle
From: Predator <cs_d607_at_king.ac.uk>
Date: 3 May 1994 18:18:12 GMT
Message-ID: <2q64h4$82r_at_mercury.king.ac.uk>
}
}
Date: 3 May 1994 18:18:12 GMT
Message-ID: <2q64h4$82r_at_mercury.king.ac.uk>
I am currently doing a piece of courework in which I have to design and implemnt a case tool using oracle and pro-c. I have become stuck in the checking routine in a delete procedure eg
printf("\nPlease enter entity id number: ");
scanf("%ld",&c_entity_id); EXEC SQL WHENEVER NOT FOUND DO no_id(); EXEC SQL SELECT * FROM ENTITY WHERE ENT_ID = :c_entity_id; if (found=='t') { EXEC SQL SELECT ENT_NAME INTO : c_entity_name FROM ENTITY WHERE ENT_ID = : c_entity_id; EXEC SQL SELECT ENT_DESCP INTO : c_entity_desc FROM ENTITY WHERE ENT_ID = : c_entity_id; EXEC SQL SELECT PROJECT_ID INTO : c_project_id FROM ENTITY WHERE ENT_ID = : c_entity_id; printf(" "); printf("Entity selected for deletion: "); printf(" "); printf("Entity Name : %s \n\n",c_entity_name); printf("Entity Description : %s \n\n",c_entity_desc); printf("Entity Project ID : %d \n\n",c_project_id); printf(" "); printf(" Are you sure you want to delete this entity ? "); scanf("%s",&answer); if (answer == 'y') { EXEC SQL DELETE FROM ENTITY WHERE ENT_ID = : c_entity_id; printf(" Record has been deleted "); } EXEC SQL COMMIT WORK; }
}
void no_id()
{
printf("\nThere is no such entity in the database. Press RETURN key to continue."); fflush(stdin); keybuffer = getchar(); found='f'; EXEC SQL WHENEVER SQLERROR CONTINUE; EXEC SQL ROLLBACK; return;
}
however everytime I run this I come up with the same error, the program keeps repeating the line 'there is no such entity etc' about 4 times. Does anyone know why this error happens and what can I do to solve it?
Orlando Kelly
The Predator
e-mail - cs_d607_at_ceres.kingston.ac.uk Received on Tue May 03 1994 - 20:18:12 CEST