Обсуждение: Database connectivity using ECPG

Поиск
Список
Период
Сортировка

Database connectivity using ECPG

От
"Jasbinder Bali"
Дата:
Hi,

I'm using ECPG to connect to my postgres database. Doing it for the very first time in my life.

The name of my database is postgres and uses a trusted connection. So, i don't think it needs any authentication parameteres like a
user name and password.

I have the follwoing line of code in my .pgc file for the database connectivity:-

EXEC SQL CONNECT TO postgres;

after compiling my .c file, i get the following error

In function `main':ecpg_test.c:(.text+0x5d): undefined reference to `ECPGconnect'

Can any1 tell me wot is this all about???

EXEC SQL CONNECT TO postgres; gets converted to
{ ECPGconnect(__LINE__, 0, "postgres" , NULL,NULL , NULL, 0); }
after ECPG does its internal conversion from .pgc to .c

Regards,
~Jas

Re: Database connectivity using ECPG

От
"Merlin Moncure"
Дата:
On 7/13/06, Jasbinder Bali <jsbali@gmail.com> wrote:
> Hi,
>
> I'm using ECPG to connect to my postgres database. Doing it for the very
> first time in my life.
>
>  In function `main':ecpg_test.c:(.text+0x5d): undefined
> reference to `ECPGconnect'

it looks like you are not linking to the ecpg library.  you need to
build it and link to it i think.  i don't know off the top of my head
if you can get ecpg library without building from source.

merlin

Re: Database connectivity using ECPG

От
John Purser
Дата:
On Thu, 13 Jul 2006 13:22:49 -0400
"Jasbinder Bali" <jsbali@gmail.com> wrote:

> Hi,
>
> I'm using ECPG to connect to my postgres database. Doing it for the
> very first time in my life.
>
> The name of my database is postgres and uses a trusted connection.
> So, i don't think it needs any authentication parameteres like a
> user name and password.
>
> I have the follwoing line of code in my .pgc file for the database
> connectivity:-
>
> EXEC SQL CONNECT TO postgres;
>
> after compiling my .c file, i get the following error
>
> In function `main':ecpg_test.c:(.text+0x5d): undefined reference to
> `ECPGconnect'
>
> Can any1 tell me wot is this all about???
>
> EXEC SQL CONNECT TO postgres; gets converted to
> { ECPGconnect(__LINE__, 0, "postgres" , NULL,NULL , NULL, 0); }
> after ECPG does its internal conversion from .pgc to .c
>
> Regards,
> ~Jas
>

It has been my impression that PosgreSQL REALLY likes to know who it's
talking to.  I'd include a user name with my connection string at the
least.

John Purser

--
Learn to pause -- or nothing worthwhile can catch up to you.

Re: Database connectivity using ECPG

От
"Shoaib Mir"
Дата:
Hi Jasbinder,

You will have to build the libecpg lib from source first and then you can build your C source (got from .pgc file using ecpg) using something like this:

cc -I <postgres include folder> -c sample.c
cc -o sample sample.o -L <folder where libecpg is located> -lecpg

Thanks,

Shoaib Mir
EnterpriseDB

On 7/13/06, John Purser < jmpurser@gmail.com> wrote:
On Thu, 13 Jul 2006 13:22:49 -0400
"Jasbinder Bali" < jsbali@gmail.com> wrote:

> Hi,
>
> I'm using ECPG to connect to my postgres database. Doing it for the
> very first time in my life.
>
> The name of my database is postgres and uses a trusted connection.
> So, i don't think it needs any authentication parameteres like a
> user name and password.
>
> I have the follwoing line of code in my .pgc file for the database
> connectivity:-
>
> EXEC SQL CONNECT TO postgres;
>
> after compiling my .c file, i get the following error
>
> In function `main':ecpg_test.c:(.text+0x5d): undefined reference to
> `ECPGconnect'
>
> Can any1 tell me wot is this all about???
>
> EXEC SQL CONNECT TO postgres; gets converted to
> { ECPGconnect(__LINE__, 0, "postgres" , NULL,NULL , NULL, 0); }
> after ECPG does its internal conversion from .pgc to .c
>
> Regards,
> ~Jas
>

It has been my impression that PosgreSQL REALLY likes to know who it's
talking to.  I'd include a user name with my connection string at the
least.

John Purser

--
Learn to pause -- or nothing worthwhile can catch up to you.

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings