From: | "Jasbinder Bali" <jsbali(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | ECPG usage |
Date: | 2006-07-20 19:56:34 |
Message-ID: | a47902760607201256x57bb49bw8fc2301aaf2befc9@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Eric Faulhaber | 2006-07-20 20:06:20 | Re: UTF8 conversion differences from v8.1.3 to v8.1.4 |
Previous Message | Jasbinder Bali | 2006-07-20 19:53:10 | calling stored procedure using ECPG |