Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > main-testing > by-pkgid > bab02a23fa9f3df8d66a9a3231b50245 > files > 102

postgresql8.3-docs-8.3.6-2mdv2008.1.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>dblink_connect</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 8.3.6 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="dblink"
HREF="dblink.html"><LINK
REL="PREVIOUS"
TITLE="dblink"
HREF="dblink.html"><LINK
REL="NEXT"
TITLE="dblink_connect_u"
HREF="contrib-dblink-connect-u.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2009-02-03T04:34:16"></HEAD
><BODY
CLASS="REFENTRY"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
>PostgreSQL 8.3.6 Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="dblink.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="dblink.html#AEN99524"
>Fast Backward</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="contrib-dblink-connect-u.html"
>Fast Forward</A
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="contrib-dblink-connect-u.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="CONTRIB-DBLINK-CONNECT"
></A
>dblink_connect</H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN99528"
></A
><H2
>Name</H2
>dblink_connect&nbsp;--&nbsp;opens a persistent connection to a remote database</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN99531"
></A
><H2
>Synopsis</H2
><PRE
CLASS="SYNOPSIS"
>    dblink_connect(text connstr) returns text
    dblink_connect(text connname, text connstr) returns text
   </PRE
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN99533"
></A
><H2
>Description</H2
><P
>    <CODE
CLASS="FUNCTION"
>dblink_connect()</CODE
> establishes a connection to a remote
    <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> database.  The server and database to
    be contacted are identified through a standard <SPAN
CLASS="APPLICATION"
>libpq</SPAN
>
    connection string.  Optionally, a name can be assigned to the
    connection.  Multiple named connections can be open at once, but
    only one unnamed connection is permitted at a time.  The connection
    will persist until closed or until the database session is ended.
   </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN99539"
></A
><H2
>Arguments</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="PARAMETER"
>conname</TT
></DT
><DD
><P
>       The name to use for this connection; if omitted, an unnamed
       connection is opened, replacing any existing unnamed connection.
      </P
></DD
><DT
><TT
CLASS="PARAMETER"
>connstr</TT
></DT
><DD
><P
>       <SPAN
CLASS="APPLICATION"
>libpq</SPAN
>-style connection info string, for example
       <TT
CLASS="LITERAL"
>hostaddr=127.0.0.1 port=5432 dbname=mydb user=postgres
       password=mypasswd</TT
>.
       For details see <CODE
CLASS="FUNCTION"
>PQconnectdb</CODE
> in
       <A
HREF="libpq-connect.html"
>Section 30.1</A
>.
      </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN99556"
></A
><H2
>Return Value</H2
><P
>    Returns status, which is always <TT
CLASS="LITERAL"
>OK</TT
> (since any error
    causes the function to throw an error instead of returning).
   </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN99560"
></A
><H2
>Notes</H2
><P
>    Only superusers may use <CODE
CLASS="FUNCTION"
>dblink_connect</CODE
> to create
    non-password-authenticated connections.  If non-superusers need this
    capability, use <CODE
CLASS="FUNCTION"
>dblink_connect_u</CODE
> instead.
   </P
><P
>    It is unwise to choose connection names that contain equal signs,
    as this opens a risk of confusion with connection info strings
    in other <TT
CLASS="FILENAME"
>dblink</TT
> functions.
   </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN99567"
></A
><H2
>Example</H2
><PRE
CLASS="PROGRAMLISTING"
> select dblink_connect('dbname=postgres');
  dblink_connect
 ----------------
  OK
 (1 row)

 select dblink_connect('myconn', 'dbname=postgres');
  dblink_connect
 ----------------
  OK
 (1 row)
   </PRE
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="dblink.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="contrib-dblink-connect-u.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>dblink</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="dblink.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>dblink_connect_u</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>