niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » PostgreSQL
ECPG usage
Post new topic   Reply to topic Page 1 of 1 [1 Post] View previous topic :: View next topic
Author Message
Jasbinder Bali
*nix forums beginner


Joined: 14 Jun 2006
Posts: 23

PostPosted: Thu Jul 20, 2006 7:56 pm    Post subject: ECPG usage Reply with quote

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
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [1 Post] View previous topic :: View next topic
The time now is Mon Dec 01, 2008 6:20 pm | All times are GMT
navigation Forum index » Databases » PostgreSQL
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts ECPG (usage of simple select statement) Jasbinder Bali PostgreSQL 0 Fri Jul 21, 2006 3:28 am
No new posts calling stored procedure using ECPG Jasbinder Bali PostgreSQL 1 Thu Jul 20, 2006 7:53 pm
No new posts High paging usage on database process mychrislo@gmail.com AIX 0 Wed Jul 19, 2006 9:59 am
No new posts df - k/ usage 100% how clear spatial/ Table of contents 阿吉 Server 2 Tue Jul 18, 2006 2:15 am
No new posts Track keyboard and mouse usage dfaber python 17 Mon Jul 17, 2006 7:12 pm

Credit Cards UK | Loans | Facebook Proxy | Internet Advertising | Duwayne Burnside
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1817s ][ Queries: 16 (0.0993s) ][ GZIP on - Debug on ]