From: | James Thompson <jamest(at)math(dot)ksu(dot)edu> |
---|---|
To: | Pavel PaJaSoft Janousek <janousek(at)fonet(dot)cz> |
Cc: | PgSQL Interfaces <pgsql-interfaces(at)postgreSQL(dot)org> |
Subject: | Re: [INTERFACES] ECPG & 'exec sql connect to' question |
Date: | 1999-03-04 19:17:57 |
Message-ID: | Pine.LNX.4.10.9903041307010.4157-100000@hobbes.math.ksu.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-interfaces |
On Thu, 4 Mar 1999, Pavel PaJaSoft Janousek wrote:
> Hi all,
>
> I've one big problem. Last month I saw in this mailing-list one example, where was this line:
>
> 'exec sql connect to unix:postgresql://localhost:5432/mm; '
>
Here is a copy of the subroutine I use. I'm pretty sure it worked fine
with 6.4.2 and the ecpg that came with it. The obstrdup() is a simple
string copy function, obstrappend appends the second string arg to the
first. You should be able to get rid of them easily, if not I'll send you
those as well. Hope this helps.
int
db_connect(char *username, char *password, char *host)
{
exec sql begin declare section;
char *xpassword;
char *xusername;
char *xhost;
exec sql end declare section;
assert (username != NULL);
assert (password != NULL);
xpassword = obstrdup(password);
xusername = obstrdup(username);
if (host)
{
xhost = obstrdup("tcp:postgresql://");
xhost = obstrappend(xhost,host);
xhost = obstrappend(xhost,"/obe");
} else {
xhost = obstrdup("tcp:postgresql://127.0.0.1/obe");
}
/* <tcp|unix>:postgresql://server[:port][/dbname][?options] */
EXEC SQL CONNECT TO :xhost USER :xusername IDENTIFIED BY :xpassword;
return 0;
}
->->->->->->->->->->->->->->->->->->---<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<
James Thompson 138 Cardwell Hall Manhattan, Ks 66506 785-532-0561
Kansas State University Department of Mathematics
->->->->->->->->->->->->->->->->->->---<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Davis | 1999-03-04 21:18:18 | question about looping through records in plpgsql |
Previous Message | Viktor A. | 1999-03-04 17:15:51 | Re: [GENERAL] I can't drop view?! |
From | Date | Subject | |
---|---|---|---|
Next Message | Valerio Santinelli | 1999-03-04 21:26:13 | Re: [INTERFACES] Foreign Keys |
Previous Message | Viktor A. | 1999-03-04 17:14:34 | Re: [INTERFACES] libpq++ - copy - default values |