Re: [INTERFACES] ECPG & 'exec sql connect to' question

Поиск
Список
Период
Сортировка
От James Thompson
Тема Re: [INTERFACES] ECPG & 'exec sql connect to' question
Дата
Msg-id Pine.LNX.4.10.9903041307010.4157-100000@hobbes.math.ksu.edu
обсуждение исходный текст
Ответ на ECPG & 'exec sql connect to' question  ("Pavel PaJaSoft Janousek" <janousek@fonet.cz>)
Список 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
->->->->->->->->->->->->->->->->->->---<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<




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

Предыдущее
От: "Viktor A."
Дата:
Сообщение: Re: [INTERFACES] libpq++ - copy - default values
Следующее
От: Valerio Santinelli
Дата:
Сообщение: Re: [INTERFACES] Foreign Keys