From: Bruce Tenison <btenison@rstc.cc.al.us>
To: pgsql-interfaces@hub.org
Subject: ECPG Question
Date: Wed, 20 Jan 1999 11:35:59 -0600
Message-ID: <000c01be449b$57fa6580$0105a8c0@tenison.irstc.cc.al.us> (raw)
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;
}
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-interfaces@postgresql.org
Cc: btenison@rstc.cc.al.us, pgsql-interfaces@hub.org
Subject: Re: ECPG Question
In-Reply-To: <000c01be449b$57fa6580$0105a8c0@tenison.irstc.cc.al.us>
References: <000c01be449b$57fa6580$0105a8c0@tenison.irstc.cc.al.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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