pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedECPG Question
3+ messages / 2 participants
[nested] [flat]
* ECPG Question
@ 1999-01-20 17:35 Bruce Tenison <btenison@rstc.cc.al.us>
1999-01-20 20:02 ` Re: [INTERFACES] ECPG Question Michael Meskes <Michael_Meskes@usa.net>
0 siblings, 1 reply; 3+ messages in thread
From: Bruce Tenison @ 1999-01-20 17:35 UTC (permalink / raw)
To: pgsql-interfaces@hub.org
Hi! I hope that I'm in the correct list to ask this question. We have a
daemon that need to access our PostgreSQL database and have been trying to
use ecpg to generate the C source to use to access the database. Basically,
we're winding up with a bunch of open sockets for some reason. Here's the
function that accesses the database, and I'm wondering if we're closing the
connection properly (since we call this routine quite often...)
Thanks!
Bruce
int getuname(ipaddr)
char *ipaddr;
{
ECPGconnect("currentuser");
if (SQLCODE > 0) {
set_not_found_uname ();
} else {
unset_not_found_uname ();
}
if(sqlca.sqlcode) {
syslog(LLEV,"Error connecting to database server.\n");
exit(0);
}
/* First, let's check to see if the IP address exists in the database */
ECPGdo(__LINE__, "SELECT userid FROM usernames WHERE ipaddr = ;; ",
ECPGt_char,ipaddr,0L,0L,sizeof(char), ECPGt_EOIT,
ECPGt_char,&username,9L,0L,sizeof(char), ECPGt_EORT );
if (SQLCODE > 0) {
set_not_found_uname ();
} else {
unset_not_found_uname ();
}
ECPGtrans(__LINE__, "end");
return not_found_uname;
}
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [INTERFACES] ECPG Question
1999-01-20 17:35 ECPG Question Bruce Tenison <btenison@rstc.cc.al.us>
@ 1999-01-20 20:02 ` Michael Meskes <Michael_Meskes@usa.net>
1999-01-21 18:01 ` RE: [INTERFACES] ECPG Question Bruce Tenison <btenison@rstc.cc.al.us>
0 siblings, 1 reply; 3+ messages in thread
From: Michael Meskes @ 1999-01-20 20:02 UTC (permalink / raw)
To: Bruce Tenison <btenison@rstc.cc.al.us>; +Cc: pgsql-interfaces
On Wed, Jan 20, 1999 at 11:35:59AM -0600, Bruce Tenison wrote:
> Hi! I hope that I'm in the correct list to ask this question. We have a
Yes.
> daemon that need to access our PostgreSQL database and have been trying to
> use ecpg to generate the C source to use to access the database. Basically,
> we're winding up with a bunch of open sockets for some reason. Here's the
> function that accesses the database, and I'm wondering if we're closing the
> connection properly (since we call this routine quite often...)
The function listed below is not an embedded sql function as preprocessed by
ecpg. It only uses libecpg. Or is this the result of an ecpg run?
> int getuname(ipaddr)
> char *ipaddr;
> {
> ECPGconnect("currentuser");
ECPGconnect is used to connect to a database. So you open a connection to DB
currentuser everytime you call this function.
> ...
> ECPGtrans(__LINE__, "end");
>
> return not_found_uname;
> }
This only commits the transaction but does not disconnect from the database.
For that you need a call to ECPGfinish as done in ECPGdisconnect.
Michael
--
Michael Meskes | Go SF 49ers!
Th.-Heuss-Str. 61, D-41812 Erkelenz | Go Rhein Fire!
Tel.: (+49) 2431/72651 | Use Debian GNU/Linux!
Email: Michael.Meskes@gmx.net | Use PostgreSQL!
^ permalink raw reply [nested|flat] 3+ messages in thread
* RE: [INTERFACES] ECPG Question
1999-01-20 17:35 ECPG Question Bruce Tenison <btenison@rstc.cc.al.us>
1999-01-20 20:02 ` Re: [INTERFACES] ECPG Question Michael Meskes <Michael_Meskes@usa.net>
@ 1999-01-21 18:01 ` Bruce Tenison <btenison@rstc.cc.al.us>
0 siblings, 0 replies; 3+ messages in thread
From: Bruce Tenison @ 1999-01-21 18:01 UTC (permalink / raw)
To: Michael Meskes <Michael_Meskes@usa.net>; +Cc: pgsql-interfaces
Thanks!!! That fixed our problem! I should have stated that my source was
the result of an ecpg run. We used the preprocessor to make some source
that we could manipulate, and never went back to the earlier source code.
Man this is great.
Thanks again!
Bruce
-----Original Message-----
From: Michael Meskes [mailto:Michael_Meskes@usa.net]
Sent: Wednesday, January 20, 1999 2:03 PM
To: Bruce Tenison
Cc: PostgreSQL Interfaces
Subject: Re: [INTERFACES] ECPG Question
On Wed, Jan 20, 1999 at 11:35:59AM -0600, Bruce Tenison wrote:
> Hi! I hope that I'm in the correct list to ask this question. We have a
Yes.
> daemon that need to access our PostgreSQL database and have been trying to
> use ecpg to generate the C source to use to access the database.
Basically,
> we're winding up with a bunch of open sockets for some reason. Here's the
> function that accesses the database, and I'm wondering if we're closing
the
> connection properly (since we call this routine quite often...)
The function listed below is not an embedded sql function as preprocessed by
ecpg. It only uses libecpg. Or is this the result of an ecpg run?
> int getuname(ipaddr)
> char *ipaddr;
> {
> ECPGconnect("currentuser");
ECPGconnect is used to connect to a database. So you open a connection to DB
currentuser everytime you call this function.
> ...
> ECPGtrans(__LINE__, "end");
>
> return not_found_uname;
> }
This only commits the transaction but does not disconnect from the database.
For that you need a call to ECPGfinish as done in ECPGdisconnect.
Michael
--
Michael Meskes | Go SF 49ers!
Th.-Heuss-Str. 61, D-41812 Erkelenz | Go Rhein Fire!
Tel.: (+49) 2431/72651 | Use Debian GNU/Linux!
Email: Michael.Meskes@gmx.net | Use PostgreSQL!
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~1999-01-21 18:01 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-01-20 17:35 ECPG Question Bruce Tenison <btenison@rstc.cc.al.us>
1999-01-20 20:02 ` Michael Meskes <Michael_Meskes@usa.net>
1999-01-21 18:01 ` Bruce Tenison <btenison@rstc.cc.al.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox