Re: ECPG. Badly stuck

Поиск
Список
Период
Сортировка
От Jasbinder Bali
Тема Re: ECPG. Badly stuck
Дата
Msg-id a47902760607251146k3baaee98t8a82e0e4c00bde1@mail.gmail.com
обсуждение исходный текст
Ответ на ECPG. Badly stuck  ("Jasbinder Bali" <jsbali@gmail.com>)
Ответы Re: ECPG. Badly stuck
Re: ECPG. Badly stuck
Список pgsql-general

Hi ,

Forget about cursors. Singleton queries are also not working.

Tried writing the follwoing code but doesn't give me any result.
Don't know if i have to do somethin else apart from what i've already done.



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;


        EXEC SQL INSERT INTO films VALUES (13,'',4,'2002-2-3','AA','01:01:01');

        EXEC SQL SELECT title  INTO :movie_type FROM films;

        printf("enter the type of movie %s",movie_type);

        EXEC SQL COMMIT;

}


Please let me know whats going wrong.

I'm compiling my code as follows:

[root@localhost ~]# ecpg ecpg_test.pgc
[root@localhost ~]# gcc  -o jas ecpg_test.c -lecpg -L/usr/lib/pgsql


Regards,
Jas
On 7/23/06, John Smith < john@roundel.net> wrote:
Simple:
 
EXEC SQL select foo from bar into :foo;
 
printf("foo is %s", foo);
 
 
If the select statement will return more than one row, then yes, you need to define a cursor to access it one row at a time.
 
John.


From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Jasbinder Bali
Sent: 22 July 2006 18:47
To: pgsql-general@postgresql.org
Subject: [GENERAL] ECPG. Badly stuck

Hi,
I had posted this question a few days back.
Sending the same question again.
 
I have a C program and have some ECPG code in it.
 
How do i display the data that i retrieve from the postgres database using a simple select statment or calling a stored procedure.
 
Is it mandatory to use cursor or there's  any other way to print the retrieved data..
 
Any kind of help would be highly appreciated.
Thanks,
~Jas

В списке pgsql-general по дате отправления:

Предыдущее
От: "Philippe Lang"
Дата:
Сообщение: Re: Plperl return_next and bytea binary data?
Следующее
От: Brad Nicholson
Дата:
Сообщение: Re: Using currval() in an insert statement...