Hi,
I have the follwing ECPG code.
-------------------------------------------------------------------------
#include <stdio.h>
EXEC SQL INCLUDE sqlca;
int main ()
{
EXEC SQL BEGIN DECLARE SECTION;
char movie_type[20];
char *movie_title=NULL;
char query_string[256];
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT TO postgres;
printf("enter the type of movie");
scanf("%s",movie_type);
sprintf(query_string,"SELECT title FROM films WHERE kind = '%s'",movie_type);
printf("query string is : '%s'\n",query_string);
EXEC SQL PREPARE s_movie FROM :query_string;
EXEC SQL DECLARE c_movie CURSOR FOR s_movie;
EXEC SQL OPEN c_movie;
EXEC SQL WHENEVER NOT FOUND DO BREAK;
while(1)
{
EXEC SQL FETCH IN c_movie INTO :movie_title;
printf("%s\n",movie_title);
movie_title = NULL;
}
free (movie_title);
EXEC SQL CLOSE c_movie;
EXEC SQL COMMIT;
EXEC SQL DISCONNECT;
return 0;
}
----------------------------------------------------------
At while loop, it keeps on looping forever and my table has 2 records for the query that is eventually build.
Does that mean EXEC SQL WHENEVER NOT FOUND DO BREAK; is not working.
Any kind of help would be appreciated.
Thanks,
~Jas
- [GENERAL] ECPG usage Jasbinder Bali
- Re: [GENERAL] ECPG usage Michael Meskes