<?xml version="1.0"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
     "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY nbsp            " ">
<!ENTITY LIBGDA          "<application>libgda</application>">
<!ENTITY GNOMEDB         "<application>GNOME-DB</application>">
<!ENTITY igalia          '<emphasis><ulink url="http://www.igalia.com">Igalia, S.L.</ulink></emphasis>'>
<!ENTITY API             "<acronym>API</acronym>">
<!ENTITY DBMS            "<acronym>DBMS</acronym>">
<!ENTITY DSN             "<acronym>DSN</acronym>">
<!ENTITY ODBC            "<acronym>ODBC</acronym>">
<!ENTITY GDA             "<acronym>GDA</acronym>">
<!ENTITY LDAP            "<acronym>LDAP</acronym>">
<!ENTITY CORBA           "<acronym>CORBA</acronym>">
<!ENTITY IDL             "<acronym>IDL</acronym>">
<!ENTITY ORB             "<acronym>ORB</acronym>">
<!ENTITY SQL             "<acronym>SQL</acronym>">
<!ENTITY RPM             "<acronym>RPM</acronym>">
<!ENTITY XML             "<acronym>XML</acronym>">
<!ENTITY PGSQL           "<application>PostgreSQL</application>">
<!ENTITY MYSQL           "<application>MySQL</application>">
<!ENTITY ORAC            "<application>Oracle</application>">
<!ENTITY INTERB          "<application>Interbase</application>">
<!ENTITY SYBASE          "<application>Sybase</application>">
<!ENTITY MSACC           "<application>MS Access</application>">
<!ENTITY INFOR           "<application>Informix</application>">
<!ENTITY GDASERVERPROVIDER "<xref linkend='libgda-GdaServerProvider'>GdaServerProvider</xref>">
<!ENTITY GDADATAMODEL    "<xref linkend='libgda-GdaDataModel'>GdaDataModel</xref>">
<!ENTITY GDADATAMODELARRAY "<xref linkend='libgda-GdaDataModelArray'>GdaDataModelArray</xref>">
<!ENTITY GDADATAMODELHASH "<xref linkend='libgda-GdaDataModelHash'>GdaDataModelHash</xref>">
<!ENTITY fullexample SYSTEM "examples/full_example.c">
<!ENTITY migration.sgml SYSTEM "migration.sgml">
<!ENTITY libgda-blob SYSTEM "xml/gda-blob.xml">
<!ENTITY libgda-client SYSTEM "xml/gda-client.xml">
<!ENTITY libgda-command SYSTEM "xml/gda-command.xml">
<!ENTITY libgda-config SYSTEM "xml/gda-config.xml">
<!ENTITY libgda-connection SYSTEM "xml/gda-connection.xml">
<!ENTITY libgda-data-model-array SYSTEM "xml/gda-data-model-array.xml">
<!ENTITY libgda-data-model-hash SYSTEM "xml/gda-data-model-hash.xml">
<!ENTITY libgda-data-model-list SYSTEM "xml/gda-data-model-list.xml">
<!ENTITY libgda-data-model SYSTEM "xml/gda-data-model.xml">
<!ENTITY libgda-error SYSTEM "xml/gda-error.xml">
<!ENTITY libgda-export SYSTEM "xml/gda-export.xml">
<!ENTITY libgda-field SYSTEM "xml/gda-field.xml">
<!ENTITY libgda-init SYSTEM "xml/libgda.xml">
<!ENTITY libgda-log SYSTEM "xml/gda-log.xml">
<!ENTITY libgda-parameter SYSTEM "xml/gda-parameter.xml">
<!ENTITY libgda-quark-list SYSTEM "xml/gda-quark-list.xml">
<!ENTITY libgda-row SYSTEM "xml/gda-row.xml">
<!ENTITY libgda-select SYSTEM "xml/gda-select.xml">
<!ENTITY libgda-server-provider SYSTEM "xml/gda-server-provider.xml">
<!ENTITY libgda-table SYSTEM "xml/gda-table.xml">
<!ENTITY libgda-transaction SYSTEM "xml/gda-transaction.xml">
<!ENTITY libgda-util SYSTEM "xml/gda-util.xml">
<!ENTITY libgda-value SYSTEM "xml/gda-value.xml">
<!ENTITY libgda-xml-connection SYSTEM "xml/gda-xml-connection.xml">
<!ENTITY libgda-xml-database SYSTEM "xml/gda-xml-database.xml">
<!ENTITY libgda-xml-document SYSTEM "xml/gda-xml-document.xml">
<!ENTITY libgda-xql-atom SYSTEM "xml/gda-xql-atom.xml">
<!ENTITY libgda-xql-bin SYSTEM "xml/gda-xql-bin.xml">
<!ENTITY libgda-xql-column SYSTEM "xml/gda-xql-column.xml">
<!ENTITY libgda-xql-const SYSTEM "xml/gda-xql-const.xml">
<!ENTITY libgda-xql-delete SYSTEM "xml/gda-xql-delete.xml">
<!ENTITY libgda-xql-dml SYSTEM "xml/gda-xql-dml.xml">
<!ENTITY libgda-xql-dual SYSTEM "xml/gda-xql-dual.xml">
<!ENTITY libgda-xql-field SYSTEM "xml/gda-xql-field.xml">
<!ENTITY libgda-xql-func SYSTEM "xml/gda-xql-func.xml">
<!ENTITY libgda-xql-insert SYSTEM "xml/gda-xql-insert.xml">
<!ENTITY libgda-xql-item SYSTEM "xml/gda-xql-item.xml">
<!ENTITY libgda-xql-join SYSTEM "xml/gda-xql-join.xml">
<!ENTITY libgda-xql-list SYSTEM "xml/gda-xql-list.xml">
<!ENTITY libgda-xql-query SYSTEM "xml/gda-xql-query.xml">
<!ENTITY libgda-xql-select SYSTEM "xml/gda-xql-select.xml">
<!ENTITY libgda-xql-stack SYSTEM "xml/gda-xql-stack.xml">
<!ENTITY libgda-xql-target SYSTEM "xml/gda-xql-target.xml">
<!ENTITY libgda-xql-update SYSTEM "xml/gda-xql-update.xml">
<!ENTITY libgda-xql-utils SYSTEM "xml/gda-xql-utils.xml">
<!ENTITY libgda-xql-value SYSTEM "xml/gda-xql-value.xml">
<!ENTITY libgda-xql-valueref SYSTEM "xml/gda-xql-valueref.xml">
<!ENTITY libgda-report-types SYSTEM "xml/gda-report-types.xml">
<!ENTITY libgda-report-document SYSTEM "xml/gda-report-document.xml">
<!ENTITY libgda-report-item SYSTEM "xml/gda-report-item.xml">
<!ENTITY libgda-report-item-detail SYSTEM "xml/gda-report-item-detail.xml">
<!ENTITY libgda-report-item-label SYSTEM "xml/gda-report-item-label.xml">
<!ENTITY libgda-report-item-pagefooter SYSTEM "xml/gda-report-item-pagefooter.xml">
<!ENTITY libgda-report-item-pageheader SYSTEM "xml/gda-report-item-pageheader.xml">
<!ENTITY libgda-report-item-repfield SYSTEM "xml/gda-report-item-repfield.xml">
<!ENTITY libgda-report-item-report SYSTEM "xml/gda-report-item-report.xml">
<!ENTITY libgda-report-item-reportfooter SYSTEM "xml/gda-report-item-reportfooter.xml">
<!ENTITY libgda-report-item-reportheader SYSTEM "xml/gda-report-item-reportheader.xml">
<!ENTITY libgda-report-item-sqlquery SYSTEM "xml/gda-report-item-sqlquery.xml">
<!ENTITY libgda-report-result SYSTEM "xml/gda-report-result.xml">
<!ENTITY libgda-report-valid SYSTEM "xml/gda-report-valid.xml">
<!ENTITY fdl-appendix SYSTEM "fdl-appendix.sgml">
]>

<book id="index">
  <bookinfo>
    <title>GNOME Data Access manual</title>
    <authorgroup>
      <author>
        <firstname>Michael</firstname>
        <surname>Lausch</surname>
        <affiliation>
          <address><email>michael.lausch@1012surf.net</email></address>
        </affiliation>
      </author>
      <author>
        <firstname>Rodrigo</firstname>
        <surname>Moya</surname>
        <affiliation>
          <address><email>rodrigo@gnome-db.org</email></address>
        </affiliation>
      </author>
      <author>
        <firstname>Vivien</firstname>
        <surname>Malerba</surname>
        <affiliation>
          <address><email>malerba@gnome-db.org</email></address>
        </affiliation>
      </author>
      <author role="clean up">
	<firstname>Sean</firstname>
	<surname>Allen</surname>
	<affiliation>
	  <address><email>zeroone@worldonline.co.za</email></address>
	</affiliation>
	<contrib>GDP compliance, FDL, added mark-up, English and syntax
        </contrib>
      </author>
      <author>
	<firstname>Xabier</firstname>
	<surname>Rodriguez Calvar</surname>
	<affiliation>
          <orgname>&igalia;</orgname>
	  <address><email>xrcalvar@igalia.com</email></address>
	</affiliation>
	<contrib>How to begin and migration formulae
        </contrib>
      </author>
      <author>
	<firstname>Jose</firstname>
	<surname>Dapena Paz</surname>
	<affiliation>
          <orgname>&igalia;</orgname>
	  <address><email>jdapena@igalia.com</email></address>
	</affiliation>
	<contrib>Some examples
        </contrib>
      </author>
    </authorgroup>
    <date>1999 February</date>
    <copyright>
      <year>1999-2003</year>
      <holder>The GNOME Foundation</holder>
    </copyright>
    <abstract>
      <para>
        GNOME Data Access (&GDA;) is an architecture whose 
        purpose is to provide universal access to many different kinds and
        types of data sources. This goes from traditional relational database
        systems, to any imaginable kind of data source such as a mail server,
        a &LDAP; directory...
      </para>
      <para>
        This universality is obtained through the use of
        an easily extensible plug-in system as the mechanism for
	communication between the different components in the architecture.
      </para>
    </abstract>
    <legalnotice id="legalnotice">
      <para>
        Permission is granted to copy, distribute and/or modify this document
        under the terms of the <link linkend="fdl"><citetitle>GNU
        Free Documentation License</citetitle></link>, Version 1.1 or any later
        version published by the Free Software Foundation with no Invariant
        Sections, no Front-Cover Texts, and no Back-Cover Texts.  A copy of the
        license can be found in <xref linkend="fdl">the appendix</xref>.
      </para>
      <para>
        Many of the names used by companies to distinguish their products and
        services are claimed as trademarks. Where those names appear in any
        GNOME documentation, and those trademarks are made aware to the members
        of the GNOME Documentation Project, the names have been printed in caps
        or initial caps.
      </para>
    </legalnotice>
  </bookinfo>

  <chapter id="introduction">
    <title>Introduction</title>
    <para>
      &ODBC; and &SQL; are established standards. The problem is, that &ODBC;
      doesn't specify the wire protocol and for some databases no &ODBC; driver
      exists. You might use <acronym>RPC</acronym>, <acronym>TCP/IP</acronym>,
      or shared memory and signals to pass the request from the client to the
      server. So you have to use the database specific &ODBC; library. This 
      library might not be available for the <acronym>CPU</acronym> or 
      operating system on which the client is running. 
    </para>
    <para>
      &SQL; itself is also not standardised enough, so that source
      compatibility can not be assured for all database servers. And for some
      sort of servers, &SQL; is not even feasible (think about &LDAP;).
    </para>
    <para>
      &GDA; tries to tackle the &ODBC; problem and help you with the &SQL;
      problem. It's a sort of middleware (or can be blown up to be a middleware
      layer) to access different data sources. It offers a high level view of
      data sources and has some places where you can plug in low level access
      to the database for special tasks.
    </para>
    <para>
      GNOME Data Access (&GDA;) is defined as a set of plug-in interfaces.
      The level of abstraction provided by &GDA; makes it possible to access
      any kind of data source, provided that a plug-in implementing 
      those interfaces and accessing this particular data source is
      written.
    </para>
    <para>
      It offers a wrapper around the database internals, thus making it easier
      for programmers to make use of all the power provided by many RDBMS without
      even knowing about it. It comes along with a library, for both
      clients and servers, as a C implementation of this architecture. This level of
      abstraction would make possible to, at a later time, change all the
      internals without having to modify applications using the libraries.
    </para>
    <para>
      Along with these libraries (and associated header files and language 
      bindings for development), &LIBGDA; includes several tools and utilities
      to help you with the task of developing applications based on &LIBGDA;,
      as well as for automating some database-related tasks.
    </para>
    <para>
      &LIBGDA; is implemented for <systemitem class="osname">UNIX
      </systemitem>-like operating systems (including <systemitem 
      class="osname">Linux</systemitem>), and does not depend on other 
      libraries apart from  <systemitem class="resource">libxml2</systemitem> and 
      <systemitem class="resource">Glib</systemitem>, which makes it a very
      lightweight system also ideal for applications to be run on 
      hardware-limited systems. It was once part of the &GNOMEDB; project, and
      is still used as the basis for it, but it's been separated from it to
      remove all GNOME dependencies and thus allow non-GNOME applications to
      be developed based on it.
    </para>
  </chapter>
  
  <chapter id="architecture">
    <title>&LIBGDA; architecture</title>
    <para>
      &LIBGDA; is composed of three independent layers. The lower level is
      covered by the &GDA; providers, which are plug-ins whose task is
      to map the <acronym>RDBMS</acronym>-specific &API; to the &GDA; model.
      That is, they are objects implementing the &GDA; interfaces.
    </para>
    <para>
      Then, in a middle layer, are the client libraries: an easy-to-use and
      full featured library which offers access to all the architecture,
      also including several utility functions to help you on the development
      of applications based on &GDA;. This library, although targeted to client
      applications, also includes a set of helper classes and functions to help
      in the addition of new providers to the &LIBGDA; architecture.
    </para>
    <para>
      Finally, at the upper level sit all the client applications provided in
      the suite, as well as any application that may make use of the client
      libraries.
    </para>
  </chapter>
  
  <chapter id="installation">
    <title>Installation</title>
    <sect1 id="installation-introduction">
      <title>Introduction</title>
      <para>
        On our web site, <ulink url="http://www.redhat.com"
        type="http">RedHat</ulink> and <ulink
        url="http://www.debian.org" type="http">Debian</ulink>
        packages are available, so you shouldn't have any problem
        installing it. For a standard installation, there is are no
        further steps, but, you'd better know configuration options,
        just in case you come across a non-standard installation, or
        in case of problems during a standard installation.
      </para>
    </sect1>
    <sect1 id="installation-installing">
      <title>Installing</title>
      <para>
        Installation depends on which format you choose to download. If
        you've got a package such as &RPM; or <acronym>DEB</acronym>, check
        your package manager documentation for how to install new packages.
      </para>
      <para>
        If you downloaded the source code (in a tarball), you must
        compile the software. To do so, once you have unpacked
        the source tree, you must:
        <programlisting>
          <prompt>$</prompt> <userinput>./configure</userinput>
          <prompt>$</prompt> <userinput>make</userinput>
          <prompt>$</prompt> <userinput>make install</userinput>
        </programlisting>
      </para>
      <para>
        This will generate the makefiles for your specific platform,
        compile all the source tree, and install the binaries and
        documentation in your system.
      </para>
      <para>
        If you don't find a file named <filename>configure</filename>, there
        should be one called <filename>autogen.sh</filename>. In this case,
        run <filename>autogen.sh</filename>, which will create and run the
        generated <filename>configure</filename> file.
      </para>
      <para>
        You can specify several arguments to <filename>configure</filename> (or
        <filename>autogen.sh</filename>). The most significant are (you can
        check all the available arguments by running
        <command>configure --help</command>):
      </para>
      <itemizedlist mark="bullet">
        <listitem>
          <para>
            <userinput>--prefix=&lt;directory&gt;</userinput>: Prefix where
             package will be installed
          </para>
        </listitem>
        <listitem>
          <para>
            <userinput>--with-mysql=&lt;directory&gt;</userinput>: Specify
            directory where &MYSQL; libraries are installed
          </para>
        </listitem>
        <listitem>
          <para>
            <userinput>--with-postgres=&lt;directory&gt;</userinput>:
            Specify directory where &PGSQL; libraries are installed
          </para>
        </listitem>
        <listitem>
          <para>
            <userinput>--with-sybase=&lt;directory&gt;</userinput>: Specify
            directory where &SYBASE; libraries are installed
          </para>
        </listitem>
        <listitem>
          <para>
            <userinput>--with-ldap=&lt;directory&gt;</userinput>: Specify
             directory where &LDAP; libraries are installed
          </para>
        </listitem>
        <listitem>
          <para>
            <userinput>--with-oracle=&lt;directory&gt;</userinput>: Specify
            directory where &ORAC; libraries are installed
          </para>
        </listitem>
        <listitem>
          <para>
            <userinput>--with-interbase=&lt;directory&gt;</userinput>: Specify
            directory where &INTERB; libraries are installed
          </para>
        </listitem>
        <listitem>
          <para>
            <userinput>--with-mdb=&lt;directory&gt;</userinput>: Specify
            directory where the MDB libraries (for accessing &MSACC; files)
            are installed
          </para>
        </listitem>
	<listitem>
          <para>
            <userinput>--with-sqlite=&lt;directory&gt;</userinput>: Specify
            directory where the SQLite libraries are installed
          </para>
        </listitem>
      </itemizedlist>
      <para>
        Libraries needed by providers are searched by default, so, if found, providers are
	compiled by default. Those libraries are searched in hard-coded directories, so
	if the installation of these libraries is in an uncommon place, the above arguments
	should be used to specify the directories where the libraries and header files
	are installed.
      </para>
      <para>
        If you find any problem during the configuration, compilation or
        installation process, do not hesitate in contacting the
        &GNOMEDB; mailing list (<email>gnome-db-list@gnome.org</email>, first
        send an email to <email>gnome-db-list-request@gnome.org</email> with 
        the subject SUBSCRIBE, if you are not already subscribed).
      </para>
      <sect2 id="installation-debian">
        <title>Debian installation</title>
          <para>
            If you are using <ulink url="http://www.debian.org">Debian</ulink> you
	    will need to install a few packages in the following way:
	  </para>
          <programlisting>
            <systemitem class="prompt">$</systemitem> <userinput> apt-get install <replaceable>package-names</replaceable></userinput>
          </programlisting>
          <para>
            These are the packages you will need for this:
          </para>
          <itemizedlist>
          <listitem><para>libgda2-1</para></listitem>
            <listitem><para>libgda2-common</para></listitem>
            <listitem><para>libgda2-dev</para></listitem>
            <listitem><para>libgda2-doc</para></listitem>
            <listitem><para>libgda2-dbg</para></listitem>
            <listitem><para>libgda2-ruby (Ruby bindings)</para></listitem>
          </itemizedlist>
	  <para>
	    Alternatively, you can install the different providers that allow access to the
	    different supported data sources. The packages you can choose from are:
	  </para>
	  <itemizedlist>
          <listitem><para>gda2-postgres for PostgreSQL databases</para></listitem>
            <listitem><para>gda2-mysql for MySQL databases</para></listitem>
            <listitem><para>gda2-odbc for ODBC data sources</para></listitem>
            <listitem><para>gda2-freetds for Sybase and MS SQL Server databases</para></listitem>
            <listitem><para>gda2-sqlite for SQLite databases</para></listitem>
          </itemizedlist>
          <para>
            You can obtain information about any packages with:
          </para>
          <programlisting>
            <systemitem class="prompt">$</systemitem> <userinput> apt-cache show <replaceable>package-names</replaceable></userinput>
          </programlisting>
          <para>
            If you cannot find this packages, you must include in
            <filename class="directory">/etc/apt/sources.list</filename>
            a line like this:
          </para>
          <programlisting>
            deb http://gluck.debian.org/~kov/debian woody gnome2
          </programlisting>
      </sect2>
    </sect1>
    <sect1 id="compiling">
      <title>Compiling with the library</title>
        <para>
          To compile you will need to set the C flags and to link the library, so we recommend
          to use the <emphasis>pkg-config</emphasis> command.
        </para>
        <programlisting>
          <systemitem class="prompt">$</systemitem> <userinput> gcc -c full_example.c `pkg-config --cflags libgda`</userinput>
          <systemitem class="prompt">$</systemitem> <userinput> gcc -o full_example `pkg-config --libs libgda` full_example.o</userinput>
        </programlisting>
	<para>
	  Doing this will add to the C compiler command line all needed header files
	  and library directories as well as all needed libraries for linking your GDA
	  application. To include header files, you can just use <filename>libgda/libgda.h</filename>,
	  which will include all GDA header files.
	</para>
    </sect1>
    <sect1 id="installation-configuring">
      <title>Configuring</title>
      <para>
        Depending on the use you're going to get out of &LIBGDA;, you may have
        to dig deep into its internals, but don't be afraid, things have been
        implemented to be easy to use.
      </para>
      <sect2 id="installation-development">
        <title>Configuration for development</title>
        <para>
          If you want to develop applications using &LIBGDA;, you should 
          install the libgda-dev[el] package if you do a &RPM; or <link
	  linkend="installation-debian">Debian-based</link>
          installation. If you compiled the source code, development files are
          installed in your system.
        </para>
        <para>
          The only step you need to do to make sure everything is well 
          installed, is to check that &LIBGDA; libraries and binaries are seen
          by your system. That is, make sure that the &LIBGDA; 
          <filename class="directory">bin/</filename> directory is in your
          <envar>PATH</envar> environment variable, as well as the
          <filename class="directory">lib/</filename> in your 
          <envar>LD_LIBRARY_PATH</envar> (or 
          <filename>/etc/ld.so.conf</filename> file).
        </para>
        <para>
          You have to include a headers file, and it is:
        </para>
        <programlisting>
#include &lt;libgda/libgda.h&gt;
        </programlisting>
      </sect2>
      <sect2 id="installation-client">
        <title>Configuration for accessing a database</title>
        <para>
          If you want to access a data source through a &GDA;
          provider, you must first of all have access to this provider, and
          most importantly, this provider should have access to its specific
          data source. So, first have your database up and running.
          For this, you'll have to check your specific data source
          documentation, or see the &LIBGDA; providers' specific documentation.
        </para>
        <para>
          Once you've got your &GDA; provider installed,
          whether on your machine or on another one on the network, you must
          configure your local system to have access to it. If you're on a
          local installation, once you have installed the &GDA; provider (by 
          compiling it or by installing its &RPM; or Debian package), the 
          provider is visible in your machine. This is because the provider
          installs itself in a well known location that makes &LIBGDA;
	  itself know about the new provider.
        </para>
        <para>
          Then, the next step is to configure the data sources you want
          available on your system. For doing this, you should, as for now, use
          &GNOMEDB;, which is a front-end to &LIBGDA; for the 
          <ulink url="http://www.gnome.org" type="http">GNOME project</ulink>.
          <footnote>
	    <para>
	      It would be a good idea to add a command-line tool for managing
              the configuration, as now, using <systemitem class="resource">
              GConf</systemitem>, is not a matter of hacking on a config text
              file, as it was before with <function>gnome_config</function>.
              The &API; for doing so is already available in the <filename>
              libgda-common</filename>library, so it would be really easy.
              Volunteers?
	    </para>
	  </footnote>
	</para>
	<para>
	  Command-line tools will be provided in &LIBGDA; for doing so in a
          not-too-distant future, so you may want to know what information
          you need to setup a data source.
	</para>
	<para>
	  One of the problem &GDA; solves is the naming of
          data sources. Every database system has it's own way of defining
	  names for it's databases. For example &MYSQL; uses the hostname, 
          port number, and the name of the database. Other databases, like
          Solid use the hostname and port number only. There is no support
          for multiple databases per server. Because the client does not
          need all these details, the &LIBGDA; configuration defines all the
	  properties of such a data source, so that the correct data base
          server can be contacted. This information is accessed by the
          client library and sent to the provider, which in turn will parse
          the string to decide which database must be connected to. The
          data stored for each data source is as follows:
	  
	  <programlistingco>
	    <areaspec>
	      <area id="provider" coords="2"/>
	      <area id="dsn" coords="3"/>
              <area id="description" coords="4"/>
	      <area id="username" coords="5"/>
	      <area id="password" coords="6"/>
            </areaspec>
	    <programlisting>
	      [sales]
	      Provider=MySQL
              DSN=DATABASE=test;HOST=localhost;PORT=1111
	      Description=MySQL Test Database in native mode
	      Username=username
	      Password=password
	    </programlisting>
	    <calloutlist>
	      <callout arearefs="provider">
		<para>
    		  The provider for this database is the gda-mysql
		  provider. The value of this entry is used as the
		  object ID for the plug-in activation.
		</para>
	      </callout>
	      <callout arearefs="dsn">
		<para>
		  This is the most important entry. The value of
		  this entry is the string sent to the provider so
		  that it knows which datasource to access. How this
		  entry is interpreted by the providers is described 
		  in the provider section.
		</para>
		<para>
		  There are, though, a set of default properties that can
		  be used for the connection string for all providers. Those
		  are:
		  <itemizedlist>
		    <listitem>
		      <para>USERNAME: user name to be used for authentication.</para>
		    </listitem>
		    <listitem>
		      <para>PASSWORD: password to be used for authentication.</para>
		    </listitem>
		  </itemizedlist>
		</para>
	      </callout>
	      <callout arearefs="description">
		<para>
		  The value of this entry is a short description of
		  the datasource. It is here for convenience only
		  and it is not used for any purpose.
		</para>
	      </callout>
	      <callout arearefs="username">
	        <para>
		  The user name to be used when connecting to the database.
		</para>
	      </callout>
	      <callout arearefs="password">
	        <para>
		  The password to be used when connecting to the database.
		  This is stored in plain text, so be sure you restrict access
		  to the configuration file (<filename>~/.libgda/config</filename>)
		  to any &quot;dangerous&quot; users.
		</para>
	      </callout>
	    </calloutlist>
	  </programlistingco>
	</para>
        <para>
          The &XML; configuration file (<filename
	  class="directory">~/.libgda/config</filename>) is not
	  recommended to be modified by hand and, for our example, it is
	  something like this:
        </para>
	<programlisting>
&lt;?xml version="1.0"?&gt;
&lt;libgda-config&gt;
  &lt;section path="/apps/libgda/Datasources/sales"&gt;
    &lt;entry name="DSN" type="string" value="PORT=1111;DATABASE=test;HOST=localhost"/&gt;
    &lt;entry name="Description" type="string" value="MySQL Test Database in native mode"/&gt;
    &lt;entry name="Password" type="string" value="password"/&gt;
    &lt;entry name="Provider" type="string" value="MySQL"/&gt;
    &lt;entry name="Username" type="string" value="username"/&gt;
  &lt;/section&gt;
&lt;/libgda-config&gt;
        </programlisting>
        <sect3 id="data-sources-API-functions">
        <title>Managing data sources with API functions</title>
          <sect4>
            <title>Create data sources</title>
            <para>
                      To create a data source you must use the function <link
              linkend="gda-config-save-data-source"><emphasis>gda-config-save-data-source ()
              </emphasis></link>
            </para>
            <para>
                      Here you see how to create a data source named
              <emphasis>foo_ds</emphasis>. If you do not need to give an username or password to
              enter the database, you could put <emphasis>NULL</emphasis>.
            </para>
            <programlisting>
            gda_config_save_data_source ("foo_ds", "PostgreSQL", "DATABASE=foo_db",
                                         "description of foo_ds", "foo_username", "foo_password");
            gda_config_save_data_source ("other_foo_ds", "MySQL", "DATABASE=other_foo_db,HOST=db.foo.com",
                                         "description of other_foo_ds", "foo", NULL);
            </programlisting>
            <para>
              For more details about provider specific information see in the section about
              <link linkend="installation-provider">providers specific information</link>.
            </para>
            <para>
              There was a little bug<footnote><para>It can be fixed, but it
              is better not to run the risk of it.</para></footnote>, and it
	      is that <link
	      linkend="gda-config-save-data-source">gda_config_save_data_source()</link> 
              does not create the configuration directory <filename
	      class="directory">~/.libgda</filename>, so you have to do
	      it.
            </para>
            <para>
              There is no problem about calling several times to this
	      function because if you save an existing data source, it
	      is replaced.
            </para>
          </sect4>
          <sect4>
            <title>Removing data sources</title>
            <para>
                      To remove a data source you must use the function <link
              linkend="gda-config-remove-data-source"><emphasis>gda-config-remove-data-source ()
              </emphasis></link>
            </para>
            <para>
                      Here you see how to remove a data source named
              <emphasis>foo_ds</emphasis>.
            </para>
            <programlisting>
            gda_config_remove_data_source("foo_ds");
            </programlisting>
          </sect4>
          <sect4>
            <title>Listing available data sources</title>
            <para>
                      To list available data sources you must use the function <link
              linkend="gda-config-get-data-source-list"><emphasis>gda_config_get_data_source_list ()
              </emphasis></link>
            </para>
            <para>
              Here you see a function which lists the available data sources.
            </para>
            <programlistingco>
              <areaspec units="LINECOLUMN">
                <area id="gda-config-get-data-source-list-1" coords="8 1"/>
                <area id="gda-config-get-data-source-list-2" coords="21 1"/>
              </areaspec>
              <programlisting>
              void
              list_datasources (void)
              {
                GList *ds_list;
                GList *node;
                GdaDataSourceInfo *info;
              
                ds_list = gda_config_get_data_source_list ();
              
                g_print ("\n");
                for (node = g_list_first (ds_list); node != NULL; node = g_list_next (node))
                  {
                    info = (GdaDataSourceInfo *) node->data;
              
                    g_print
                      ("NAME: %s PROVIDER: %s CNC: %s DESC: %s USER: %s PASSWORD: %s\n",
                       info->name, info->provider, info->cnc_string, info->description,
                       info->username, info->password);
              
                  }
                g_print ("\n");
              
                gda_config_free_data_source_list (ds_list);
              
              }
              </programlisting>
              <calloutlist>
                <callout arearefs="gda-config-get-data-source-list-1">
                  <para>Our function.</para>
                </callout>
                <callout arearefs="gda-config-get-data-source-list-2">
                  <para>Note that you must free the list when you finish using it.</para>
                </callout>
              </calloutlist>
            </programlistingco>
          </sect4>
          <sect4>
            <title>Listing available providers</title>
            <para>
              To list the available providers you must use the function <link
              linkend="gda-config-get-provider-list"><emphasis>gda_config_get_provider_list ()
              </emphasis></link>
            </para>
            <para>
              Here you see a function which lists available providers.
            </para>
            <programlistingco>
              <areaspec units="LINECOLUMN">
                <area id="gda-config-get-provider-list-1" coords="8 1"/>
                <area id="gda-config-get-provider-list-2" coords="19 1"/>
              </areaspec>
              <programlisting>
              void
              list_providers (void)
              {
                GList *prov_list;
                GList *node;
                GdaProviderInfo *info;
              
                prov_list = gda_config_get_provider_list ();
              
                for (node = g_list_first (prov_list); node != NULL;
                     node = g_list_next (node))
                  {
                    info = (GdaProviderInfo *) node->data;
              
                    g_print ("ID: %s\n", info->id);
              
                  }
              
                gda_config_free_provider_list (prov_list);
              
              }
              </programlisting>
              <calloutlist>
                <callout arearefs="gda-config-get-provider-list-1">
                  <para>Our function.</para>
                </callout>
                <callout arearefs="gda-config-get-provider-list-2">
                  <para>Note that you must free the list when you finish using it.</para>
                </callout>
              </calloutlist>
            </programlistingco>
          </sect4>
        </sect3>
      </sect2>
      <sect2 id="installation-provider">
        <title>Provider's specific information</title>
        <para>
          This section provides information specific to each of the available
          &LIBGDA; providers.
        </para>
	<sect3 id="installation-provider-default">
	  <title>Default provider</title>
	  <para>
	    The &GDA; default provider is always installed 
            with &LIBGDA;, which means that you've got always a default
	    database system available for you. To connect to a default 
            provider's database, you only need to specify, in the &DSN; string,
            a string of the form "URI=/path/to/the/database/file". When
            you	first connect to the new data source, the &GDA; default 
            provider will create the database, in the path you specified
            in the &DSN; string, if it does not exist. This default provider
	    uses XML as the format for that file.
	  </para>
	</sect3>
	<sect3 id="installation-provider-odbc">
	  <title>&ODBC; Provider</title>
	  <para>
	    The &ODBC; provider is a special case, since &ODBC; is itself a 
            data access layer, the same as &LIBGDA;, So, in the case of the
            &GDA; &ODBC; provider, the &DSN; string is completely up to the
            &ODBC; driver manager. That is, the &GDA; &ODBC; provider does not
            parse it all, nor does it try to understand what it means; it
            simply passes it over to the &ODBC; library.
	  </para>
	  <para>
	    So, if you want to use &LIBGDA; with &ODBC;, you should first know
            how to set up an &ODBC; data source, and then just specify the
            &DSN; string you would pass to the &ODBC; library in the &DSN;
            string of the &GDA; data sources.
	  </para>
	  <para>
	    There is a project called
	    <ulink url="http://www.unixodbc.org">unixODBC</ulink>,
            which provides some graphical tools to help you in
	    setting up &ODBC; data sources. You may find it
	    interesting to give it a try.
	  </para>
	</sect3>
	<sect3 id="installation-provider-postgres">
	  <title>&PGSQL; Provider</title>
	  <para>
	    To use the &GDA; &PGSQL; provider, you'll need
	    the <application>gda-postgres</application> package.	
	  </para>
	  <para>
	    The &PGSQL; provider accepts the following
	    arguments in the &GDA; data source's &DSN; string:
	     <itemizedlist>
	       <listitem>
	         <para>
	           HOST: name of the host where
		   the database server is running. If it begins with a slash
		   then the protocol used is Unix-domain instead of TCP/IP and
		   its value is the name of the directory where the file is
		   stored. By default: /tmp.
		 </para>
               </listitem>
	       <listitem>
		 <para>
		   HOSTADDR: IP of the host where the database server is
		   running (avoids DNS lookup). If this option has a value,
		   TCP/IP communications is used.

		   If neither a host name or host address is specified, the
		   connection will be established using a local Unix domain
		   socket.
		 </para>
	       </listitem>
	       <listitem>
	         <para>
	           PORT: Port number or socket filename extension for
		   Unix-domain connections.
		 </para>
               </listitem>
	       <listitem>
		 <para>
		   DATABASE: name of the database you want to access. This one
		   is called 'dbname' in the &PGSQL; documentation.
		 </para>
	       </listitem>
	       <listitem>
	         <para>
	           USER: user name to connect as.
		 </para>
               </listitem>
	       <listitem>
	         <para>
	           PASSWORD: password if the connection requires it.
		 </para>
               </listitem>
	       <listitem>
	         <para>
	           OPTIONS: trace/debug options to be sent to the server.
		 </para>
               </listitem>
	       <listitem>
	         <para>
	           TTY: a file or tty for optional debug output from the
		   back-end.
		 </para>
               </listitem>
	       <listitem>
	         <para>
	           REQUIRESSL: set to '1' to force SSL connection to the
		   back-end. Set to '0' to negotiate with server.
		 </para>
               </listitem>
	     </itemizedlist>
	     The description of the parameters is almost copied from the
	     &PGSQL; documentation. Refer to it for details on how some
	     environment variables can also set these parameters.
	   </para>
	 </sect3>
        <sect3 id="installation-provider-mysql">
          <title>&MYSQL; Provider</title>
          <para>
	    To configure a data source to access a &MYSQL; database,
	    you'll need to install the &GDA; &MYSQL; provider (package
	    <filename>gda-mysql</filename>).
          </para>
	  <para>
	    It accepts the following arguments in the &DSN;
	    string:	
	     <itemizedlist>
	       <listitem>
	         <para>
	           HOST: name of the host where the database server is running.
		 </para>
               </listitem>
	       <listitem>
	         <para>
	           PORT: port number for connecting to the database server.
		 </para>
               </listitem>
	       <listitem>
	         <para>
	           UNIX_SOCKET: socket file for connecting to the database server
	           (should not be defined with HOST and/or PORT).
		 </para>
               </listitem>
	       <listitem>
	         <para>
	           DATABASE: name of the database you want to access.
		 </para>
               </listitem>
	       <listitem>
	         <para>
	           USER: employ the specified user name for logging in to the
	           server.
		 </para>
               </listitem>
	       <listitem>
	         <para>
	           PASSWORD: employ the specified password when connecting to the 
	           database server.
		 </para>
               </listitem>
	       <listitem>
	         <para>
	           USE_SSL: will use SSL (encrypted protocol) if specified and set to 1.
		 </para>
               </listitem>
	     </itemizedlist>
	  </para>
        </sect3>
	<sect3 id="installation-provider-sybase">
	  <title>&SYBASE; Provider</title>
	  <para>
	    To use the &GDA; &SYBASE; provider, you'll need
	    the <application>gda-sybase</application> package.	
	  </para>
	  <para>
	    The &SYBASE; provider accepts the following
	    arguments in the &GDA; data source's &DSN; string:
	     <itemizedlist>
	       <listitem>
	         <para>
		   HOST: name of the host where the database server is
		   running.
		   </para>
               </listitem>
	       <listitem>
	         <para>
	           USERNAME: user name to connect as.
		 </para>
               </listitem>
	       <listitem>
	         <para>
	           APPNAME:
		 </para>
               </listitem>
	       <listitem>
	         <para>
	           PASSWORD: password if the connection requires it.
		 </para>
               </listitem>
	       <listitem>
		 <para>
		   DATABASE:
		 </para>
	       </listitem>
	     </itemizedlist>
	   </para>
	 </sect3>
      </sect2>
    </sect1>
  </chapter>
  <chapter id="connecting">
    <title>Beginning</title>
    <sect1 id="initializing">
      <title>Initialising</title>
      <para>
        First of all you have to initialise the gda library, i.e. to call the
        <link linkend="gda-init"><emphasis>gda_init ()</emphasis></link> function.
      </para>
      <programlisting>
        gda_init ("TestGDA", "0.1", argc, argv);
      </programlisting>
      <para>
        After initialising you can work as usual or make a function with the whole
        stuff, calling <link linkend="gda-main-run">gda_main_run()</link>. Note that
        if you use this way you will need to call <link
        linkend="gda-main-quit">gda_main_quit()</link> in order to finish the program.
      </para>
      <programlisting>
    void
    do_stuff ()
    {
      GdaClient *client;
      GdaConnection *connection;
    
      list_providers ();
      list_datasources ();
    
      client = gda_client_new ();
    
      g_print ("CONNECTING\n");
      connection = gda_client_open_connection (client, "calvaris", NULL, NULL,
					       GDA_CONNECTION_OPTIONS_READ_ONLY);

      g_print ("CONNECTED\n");
    
      execute_some_queries (connection);

      g_print ("ERRORS PROVED!\n");
    
      process_accounts(connection);
    
      gda_client_close_all_connections (client);

      g_object_unref(G_OBJECT(client));

      play_with_parameters();

      gda_main_quit();
    }
    
    
    int
    main (int argc, char **argv)
    {
    
      g_print ("STARTING\n");
      gda_init ("TestGDA", "0.1", argc, argv);
    
      save_ds ();
    
      gda_main_run ((GdaInitFunc) do_stuff, (gpointer) NULL);
      /* do_stuff(); */
      g_print("ENDING\n");
    
    }
      </programlisting>
    </sect1>
    <sect1 id="connections">
      <title>Connecting</title>
      <para>
                To connect you need to use two functions. We use
        <link linkend="gda-client-new"><emphasis>gda_client_new ()</emphasis></link>
        to create a connection pool and use
        <link linkend="gda-client-open-connection"><emphasis>gda_client_open_connection ()</emphasis></link>
        to create the specific connections to the different data sources.
      </para>
      <programlistingco>
        <areaspec units="LINECOLUMN">
          <area id="connecting-1" coords="10 1"/>
          <area id="connecting-2" coords="13 1"/>
	  <area id="connecting-3" coords="24 1"/>
	  <area id="connecting-4" coords="26 1"/>
	</areaspec>
        <programlisting>
          void
          do_stuff ()
          {
            GdaClient *client;
            GdaConnection *connection;
          
            list_providers ();
            list_datasources ();
          
            client = gda_client_new ();
          
            g_print ("CONNECTING\n");
            connection = gda_client_open_connection (client, "calvaris", NULL, NULL,
                                                     GDA_CONNECTION_OPTIONS_READ_ONLY);
      
            g_print ("CONNECTED\n");
          
            execute_some_queries (connection);
      
            g_print ("ERRORS PROVED!\n");
          
            process_accounts(connection);
          
            gda_client_close_all_connections (client);
      
            g_object_unref(G_OBJECT(client));
      
            play_with_parameters();
      
            gda_main_quit();
          }
        </programlisting>
        <calloutlist>
          <callout arearefs="connecting-1">
            <para>Creates the connection pool.</para>
          </callout>
          <callout arearefs="connecting-2">
            <para>
              Creates the connection to calvaris data source with the default username and
              password you have specify when
              <link linkend="installation-client">creating the data source</link>. However, you
              can specify them if you want.
            </para>
          </callout>
          <callout arearefs="connecting-3">
            <para>
              It's a good practice to close connections when you finish using them. It
              doesn't mean that you must close them each time you use them. It's better
              to open the connections when program starts and use them during the whole
              execution. This function frees the <link linkend="libgda-GdaConnection">GdaConnection</link>
              objects attached to the <link linkend="libgda-GdaClient">GdaClient</link>.
            </para>
          </callout>
          <callout arearefs="connecting-4">
            <para>
              When finishing with the client, I have to free it.
            </para>
          </callout>
        </calloutlist>
      </programlistingco>
    </sect1>
  </chapter>
  <chapter id="processing-queries">
    <title>Processing queries</title>
    <sect1>
      <title>Executing sentences</title>
      <sect2 id="building-commands">
        <title>Building commands</title>
        <para>
          Before invoking a query you have to build the structure containing the
          command and you can do this with <link linkend="gda-command-new">
          <emphasis>gda_command_new ()</emphasis></link>.
        </para>
        <para>
          The command type we most commonly use is <link
          linkend="GdaCommandType">GDA_COMMAND_TYPE_SQL</link> because we will only
          focus on &SQL; queries<footnote><para>There are other command types, as &XML; and so on.</para>
          </footnote>
        </para>
        <programlistingco>
          <areaspec units="LINECOLUMN">
            <area id="GdaCommandOptions-1" coords="2 1"/>
            <area id="GdaCommandOptions-2" coords="3 1"/>
          </areaspec>
          <programlisting>
          typedef enum {
                  GDA_COMMAND_OPTION_IGNORE_ERRORS  = 1,
                  GDA_COMMAND_OPTION_STOP_ON_ERRORS = 1 &lt;&lt; 1,
                  GDA_COMMAND_OPTION_BAD_OPTION     = 1 &lt;&lt; 2
          } <link linkend="GdaCommandOptions">GdaCommandOptions</link>;
          </programlisting>
          <calloutlist>
            <callout arearefs="GdaCommandOptions-1">
              <para>
                        Ignores all errors and executes all sentences returning data models.
                For failed sentences, it returns an empty data model.
              </para>
            </callout>
            <callout arearefs="GdaCommandOptions-2">
              <para>
                Stops when finding and error and doesn't return data models.
              </para>
            </callout>
          </calloutlist>
        </programlistingco>
        <para>
          Here you see an example of creating a command:
        </para>
        <programlistingco>
          <areaspec units="LINECOLUMN">
            <area id="gda-command-new-1" coords="7 1"/>
            <area id="gda-command-new-2" coords="8 1"/>
            <area id="gda-command-new-3" coords="10 1"/>
          </areaspec>
          <programlisting>
          gint
          execute_sql_non_query (GdaConnection *connection, const gchar * buffer)
          {
            GdaCommand *command;
            gint number;
          
            command = gda_command_new (buffer, GDA_COMMAND_TYPE_SQL, GDA_COMMAND_OPTION_STOP_ON_ERRORS);
            number  = gda_connection_execute_non_query (connection, command, NULL);
          
            gda_command_free (command);
          
            return (number);
          }
          </programlisting>
          <calloutlist>
            <callout arearefs="gda-command-new-1">
              <para>
                Our function. You can give it several comma-separated sentences.
              </para>
            </callout>
            <callout arearefs="gda-command-new-2">
              <para>
                We will see it <link linkend="making-queries">later</link>.
              </para>
            </callout>
            <callout arearefs="gda-command-new-3">
              <para>
                It is a good practice to free the commands.
              </para>
            </callout>
          </calloutlist>
        </programlistingco>
      </sect2>
      <sect2 id="making-queries">
        <title>Making <emphasis>non queries</emphasis></title>
        <para>
          <emphasis>Non queries</emphasis> are queries that does not return data, only the
          number of rows affected, as a DELETE or an UPDATE. We use <link
          linkend="gda-connection-execute-non-query"><emphasis>
          gda_connection_execute_non_query()</emphasis></link>
        </para>
        <programlisting>
        gint
        execute_sql_non_query (GdaConnection *connection, const gchar * buffer)
        {
          GdaCommand *command;
          gint number;
        
          command = gda_command_new (buffer, GDA_COMMAND_TYPE_SQL, GDA_COMMAND_OPTION_STOP_ON_ERRORS);
          number  = gda_connection_execute_non_query (connection, command, NULL);
        
          gda_command_free (command);
        
          return (number);
        }
        </programlisting>
      </sect2>
      <sect2 id="normal-queries">
        <title>Making normal queries</title>
        <para>
          Normal queries are queries that return data (<link
          linkend="data-model">data models</link>). You have two ways to do this:
        </para>
        <itemizedlist>
          <listitem><para>
            <link linkend="gda-connection-execute-single-command">
              gda_data_model_execute_single_command()</link></para>
          </listitem>
          <listitem><para>
            <link linkend="gda-connection-execute-command">
              gda_data_model_execute_command()</link></para>
          </listitem>
        </itemizedlist>
        <para>
          You can use the first way when you want to invoke only a single command.
          Second way is used to execute several comma-separated sentences. It is recommended
          to use <link linkend="gda-connection-execute-single-command">
          gda_connection_execute_single_command ()</link>. Here you see an
          example:
        </para>
        <programlistingco>
          <areaspec units="LINECOLUMN">
            <area id="normal-query-1" coords="13 1"/>
            <area id="normal-query-2" coords="15 1"/>
          </areaspec>
          <programlisting>
          gboolean
          execute_sql_command (GdaConnection *connection, const gchar * buffer)
          {
            GdaCommand *command;
            GList *list;
            GList *node;
            gboolean errors=FALSE;
          
            GdaDataModel *dm;
          
          
            command = gda_command_new (buffer, GDA_COMMAND_TYPE_SQL, GDA_COMMAND_OPTION_STOP_ON_ERRORS);
            list = gda_connection_execute_command (connection, command, NULL);
            if (list!=NULL)
              for (node=g_list_first(list); node != NULL; node=g_list_next(node))
                {
                  dm=(GdaDataModel *) node->data;
                  if (dm == NULL)
                    {
                      errors=TRUE;
                    }
                  else
                    {
                      show_table (dm);
                      g_object_unref(dm);
                    }
                }
            else
              {
                errors=TRUE;
              }
            gda_command_free (command);
          
            return (errors);
          }
          </programlisting>
          <calloutlist>
            <callout arearefs="normal-query-1">
              <para>
                Executes the query and obtains a list of <link linkend="data-model">data models</link>
              </para>
            </callout>
            <callout arearefs="normal-query-2">
              <para>
                Loop for moving through the list of data models. If you use <link
                linkend="gda-connection-execute-single-command">
                gda_connection_execute_single_command()</link>, you should not need to use a loop,
                because this function would return a <link linkend="data-model">data model</link>.
              </para>
            </callout>
          </calloutlist>
        </programlistingco>
      </sect2>
      </sect1>
      
    <sect1 id="data-model">
      <title>Managing <emphasis>data models</emphasis></title>
      <para>
        Each time we execute a normal query, we will obtain a <link
        linkend="libgda-GdaDataModel"><emphasis>GdaDataModel
        </emphasis></link> object, which is the way to see what the query returned. As
        <link
        linkend="libgda-GdaDataModel">GdaDataModel</link> is an object, we can manage it with <link
        linkend="libgda-GdaDataModel">GdaDataModel</link> class.
      </para>
      <para>
        Before continuing, we must say that it is possible to modify a data model, but as we
        are accessing using &SQL;, it is not recommended to modify it, so modifications on the
        database must be done using &SQL;.
      </para>
      <para>
        Let's see the functions we need:
      </para>
      <itemizedlist>
        <listitem><para>
          <link linkend="gda-data-model-get-n-rows">gda_data_model_get_n_rows()</link></para>
        </listitem>
        <listitem><para>
          <link linkend="gda-data-model-get-n-columns">gda_data_model_get_n_columns()</link></para>
        </listitem>
        <listitem><para>
          <link linkend="gda-data-model-describe-column">gda_data_model_describe_column()</link></para>
        </listitem>
        <listitem><para>
          <link linkend="gda-data-model-get-column-title">gda_data_model_get_column_title()</link></para>
        </listitem>
        <listitem><para>
          <link linkend="gda-data-model-get-column-position">gda_data_model_get_column_position()</link></para>
        </listitem>
        <listitem><para>
          <link linkend="gda-data-model-get-row">gda_data_model_get_row()</link></para>
        </listitem>
        <listitem><para>
          <link linkend="gda-data-model-get-value-at">gda_data_model_get_value_at()</link></para>
        </listitem>
        <listitem><para>
          <link linkend="gda-row-get-value">gda_row_get_value()</link></para>
        </listitem>
      </itemizedlist>
      <para>
        This functions are very easy to use, so let's see some clear 
        examples:
      </para>
      <sect2 id="data-model-table-access">
        <title>Example using direct cell access</title>
        <para>
          This function accesses the data model by directly accessing cells (using
          <link linkend="gda-data-model-get-value-at">gda_data_model_get_value_at ()
          </link>)
        </para>
        <programlistingco>
          <areaspec units="LINECOLUMN">
            <area id="data-model-1-1" coords="8 1"/>
            <area id="data-model-1-2" coords="13 1"/>
            <area id="data-model-1-3" coords="18 1"/>
          </areaspec>
          <programlisting>
          void
          show_table (GdaDataModel * dm)
          {
            gint row_id;
            gint column_id;
            GdaValue *value;
          
            for (column_id = 0; column_id &lt; gda_data_model_get_n_columns (dm);
                 column_id++)
              g_print("%s\t",gda_data_model_get_column_title (dm, column_id));
            g_print("\n");
          
            for (row_id = 0; row_id &lt; gda_data_model_get_n_rows (dm); row_id++) {
                for (column_id = 0; column_id &lt; gda_data_model_get_n_columns (dm);
                     column_id++) {
                    char *str;

                    value = gda_data_model_get_value_at (dm, column_id, row_id);
                    str = gda_value_stringify (value);
                    g_print ("%s\t", str);
                  }
                g_print("\n");
              }
          }
          </programlisting>
          <calloutlist>
            <callout arearefs="data-model-1-1">
              <para>
                Loop for writing column names.
              </para>
            </callout>
            <callout arearefs="data-model-1-2">
              <para>
                Double loop accessing values using
                <link
                linkend="gda-data-model-get-value-at">gda_data_model_get_value_at ()
                </link>
              </para>
            </callout>
            <callout arearefs="data-model-1-3">
              <para>
                Data returned is a <link linkend="libgda-gda-value">GdaValue</link> object.
              </para>
            </callout>
          </calloutlist>
        </programlistingco>
      </sect2>
      <sect2 id="data-model-row-access">
        <title>Example using row access</title>
        <para>
          This function accesses the data model by accessing rows (using
          <link linkend="gda-data-model-get-row">gda_data_model_get_row ()
          </link> and
          <link linkend="gda-row-get-value"> gda_row_get_value ()
          </link>)
        </para>
        <programlistingco>
          <areaspec units="LINECOLUMN">
            <area id="data-model-2-1" coords="10 1"/>
            <area id="data-model-2-2" coords="15 1"/>
            <area id="data-model-2-3" coords="18 1"/>
          </areaspec>
          <programlisting>
            <anchor id="show_table2">
          void
          show_table2 (GdaDataModel * dm)
          {
            gint row_id;
            gint column_id;
            GdaValue *value;
            GdaRow *row;
          
            for (column_id = 0; column_id &lt; gda_data_model_get_n_columns (dm);
                 column_id++)
              g_print("%s\t",gda_data_model_get_column_title (dm, column_id));
            g_print("\n");
          
            for (row_id = 0; row_id &lt; gda_data_model_get_n_rows (dm); row_id++) {
                row = (GdaRow *) gda_data_model_get_row (dm, row_id);
                for (column_id = 0; column_id &lt; gda_data_model_get_n_columns (dm);
                     column_id++) {
                    value = gda_row_get_value (row, column_id);
                    string=gda_value_stringify (value);
                    g_print ("%s\t", string);
                    g_free(string);
                  }
                g_print ("\n");
              }
          }
	    </anchor>
          </programlisting>
          <calloutlist>
            <callout arearefs="data-model-2-1">
              <para>
                Loop for writing column names.
              </para>
            </callout>
            <callout arearefs="data-model-2-2">
              <para>
                Outer loop obtaining rows using
                <link
                linkend="gda-data-model-get-row">gda_data_model_get_row ()
                </link>
              </para>
            </callout>
            <callout arearefs="data-model-2-3">
              <para>
                Inner loop obtaining the value using
                <link
                linkend="gda-row-get-value">gda_row_get_value ()
                </link>. Notice that <link
                linkend="gda-row-get-value">gda_row_get_value ()</link>
                returns a <emphasis>const <link
                linkend="libgda-gda-value">GdaValue</link></emphasis>, so we
                do not have to free it. 
              </para>
            </callout>
          </calloutlist>
        </programlistingco>
        
      </sect2>
      <sect2 id="data-model-free">
        <title>Freeing data models</title>
        <para>
          When you finish using data models you must free it, but GdaDataModel class
          does not have a function to do it, so you have to use <emphasis>g_object_unref
          ()</emphasis>.
        </para>
      </sect2>
    </sect1>
    <sect1 id="manage-gdavalue">
      <title>Managing values</title>
      <para>
        Values returned by functions of managing data are <link
        linkend="libgda-gda-value">GdaValue</link> objects. <link
        linkend="libgda-gda-value">GdaValue</link> class has many functions
        to access data, so we show the most important ones 
        of them:
      </para>
      <itemizedlist>
        <listitem><para>
          <link linkend="gda-value-free">gda_value_free()</link></para>
        </listitem>
        <listitem><para>
          <link linkend="gda-value-is-null">gda_value_is_null()</link></para>
        </listitem>
        <listitem><para>
          <link linkend="gda-value-copy">gda_value_copy()</link></para>
        </listitem>
        <listitem><para>
          <link linkend="gda-value-compare">gda_value_compare()</link></para>
        </listitem>
        <listitem><para>
          <link linkend="gda-value-stringify">gda_value_stringify()</link></para>
        </listitem>
      </itemizedlist>
      <para>
        There are many functions to know what is the type of a value and to manage values,
        that can be seen in <link
        linkend="libgda-gda-value">GdaValue</link> class.
      </para>
      <para>
        We will return to the examples about last section to notice some
        important details: 
      </para>
      <programlistingco>
        <areaspec units="LINECOLUMN">
          <area id="gda-value-1" coords="10 1"/>
          <area id="gda-value-2" coords="15 1"/>
          <area id="gda-value-3" coords="18 1"/>
          <area id="gda-value-4" coords="22 1"/>
        </areaspec>
        <programlisting>
        void
        show_table2 (GdaDataModel * dm)
        {
          gint row_id;
          gint column_id;
          GdaValue *value;
          GdaRow *row;
          gchar *string;
        
          for (column_id = 0; column_id &lt; gda_data_model_get_n_columns (dm);
               column_id++)
            g_print("%s\t",gda_data_model_get_column_title (dm, column_id));
          g_print("\n");
        
          for (row_id = 0; row_id &lt; gda_data_model_get_n_rows (dm); row_id++) {
              row = (GdaRow *) gda_data_model_get_row (dm, row_id);
              for (column_id = 0; column_id &lt; gda_data_model_get_n_columns (dm);
                   column_id++) {
                  value = gda_row_get_value (row, column_id);
                  string=gda_value_stringify (value);
                  g_print ("%s\t", string);
                  g_free(string);
                }
              g_print ("\n");
            }
        }
        </programlisting>
        <calloutlist>
          <callout arearefs="gda-value-1">
            <para>
              Loop for writing column names.
            </para>
          </callout>
          <callout arearefs="gda-value-2">
            <para>
              Outer loop obtaining rows using
              <link
              linkend="gda-data-model-get-row">gda_data_model_get_row ()
              </link>
            </para>
          </callout>
          <callout arearefs="gda-value-3">
            <para>
              Inner loop obtaining the value using
              <link
              linkend="gda-row-get-value">gda_row_get_value ()
              </link>. Notice that <link
              linkend="gda-row-get-value">gda_row_get_value ()
              </link> doesn't return a
              <emphasis>const <link
              linkend="libgda-gda-value">GdaValue</link></emphasis>, so we
              have to free it. 
            </para>
           </callout>
          <callout arearefs="gda-value-4">
            <para>
              We have the difference here. As you can see above, <link
              linkend="gda-value-stringify">gda_value_stringify ()</link> does not return a
              <emphasis>const</emphasis> gchar *, so you have to free it. First way is quite
              attractive but it is not good.
            </para>
          </callout>
        </calloutlist>
      </programlistingco>
    </sect1>
  </chapter>
  <chapter>
    <title>Transactions and batch processes</title>
    <sect1 id="transactions">
      <title>Managing transactions</title>
      <para>
        The special functions we need to do this are defined in the
        <link linkend="libgda-GdaTransaction">GdaTransaction</link>,
        <link linkend="libgda-GdaConnection">GdaConnection</link> and
        <link linkend="libgda-gda-command">GdaCommand</link>
        classes, and they are:
      </para>
      <itemizedlist>
        <listitem><para>
          <link linkend="gda-transaction-new">gda_transaction_new ()</link></para>
        </listitem>
        <listitem><para>
          <link linkend="gda-connection-begin-transaction">gda_connection_begin_transaction ()</link></para>
        </listitem>
        <listitem><para>
          <link linkend="gda-connection-commit-transaction">gda_connection_commit_transaction ()</link></para>
        </listitem>
        <listitem><para>
          <link linkend="gda-connection-rollback-transaction">gda_connection_rollback_transaction ()</link></para>
        </listitem>
        <listitem><para>
          <link linkend="gda-command-set-transaction">gda_command_set_transaction ()</link></para>
        </listitem>
      </itemizedlist>
      <para>
        Things you have to do to manage transactions are:
      </para>
      <orderedlist NUMERATION="arabic">
        <listitem><para>Create transaction</para></listitem>
        <listitem><para>Change, if needed, the isolation level</para></listitem>
        <listitem><para>Link transaction to a connection</para></listitem>
        <listitem>
          <para>For each command you want to execute:</para>
          <orderedlist NUMERATION="loweralpha">
            <listitem><para>Create command</para></listitem>
            <listitem><para>Link transaction to command</para></listitem>
            <listitem><para>Execute command</para></listitem>
            <listitem><para>Free command</para></listitem>
          </orderedlist>
        </listitem>
        <listitem><para>Commit or rollback transaction</para></listitem>
        <listitem><para>Free transaction</para></listitem>
      </orderedlist>
      <para>
        Here you can see an example:
      </para>
      <programlistingco>
        <areaspec units="LINECOLUMN">
          <area id="transactions-1" coords="6 1"/>
          <area id="transactions-1a" coords="7 1"/>
          <area id="transactions-2" coords="9 1"/>
          <area id="transactions-3" coords="16 1"/>
          <area id="transactions-4" coords="29 1"/>
          <area id="transactions-5" coords="30 1"/>
          <area id="transactions-6" coords="55 1"/>
        </areaspec>
        <programlisting>
        void process_accounts(GdaConnection *connection)
        {
          GdaTransaction *transaction_one, *transaction_two;
          GdaCommand *command;
        
          transaction_one=gda_transaction_new("accounts1");
          gda_transaction_set_isolation_level(transaction_one,
                   GDA_TRANSACTION_ISOLATION_SERIALIZABLE);
          gda_connection_begin_transaction(connection,transaction_one);
        
          command=gda_command_new (
                                   "UPDATE accounts SET balance=balance+50"
                                   "WHERE account_code=456",
                                   GDA_COMMAND_TYPE_SQL,
                                   GDA_COMMAND_OPTION_STOP_ON_ERRORS);
          gda_command_set_transaction(command,transaction_one);
          gda_connection_execute_non_query(connection,command,NULL);
          gda_command_free(command);
        
          command=gda_command_new (
                                   "UPDATE accounts SET balance=balance-50"
                                   "WHERE account_code=12",
                                   GDA_COMMAND_TYPE_SQL,
                                   GDA_COMMAND_OPTION_STOP_ON_ERRORS);
          gda_command_set_transaction(command,transaction_one);
          gda_connection_execute_non_query(connection,command,NULL);
          gda_command_free(command);
        
          gda_connection_commit_transaction(connection,transaction_one);
          g_object_unref(transaction_one);
        
          transaction_two=gda_transaction_new("accounts2");
          gda_transaction_set_isolation_level(transaction_two,
                   GDA_TRANSACTION_ISOLATION_SERIALIZABLE);
          gda_connection_begin_transaction(connection,transaction_two);
        
          command=gda_command_new (
                                   "UPDATE accounts SET balance=balance+400"
                                   "WHERE account_code=456",
                                   GDA_COMMAND_TYPE_SQL,
                                   GDA_COMMAND_OPTION_STOP_ON_ERRORS);
          gda_command_set_transaction(command,transaction_two);
          gda_connection_execute_non_query(connection,command,NULL);
          gda_command_free(command);
        
          command=gda_command_new (
                                   "UPDATE accounts SET balance=balance-400"
                                   "WHERE account_code=12",
                                   GDA_COMMAND_TYPE_SQL,
                                   GDA_COMMAND_OPTION_STOP_ON_ERRORS);
          gda_command_set_transaction(command,transaction_two);
          gda_connection_execute_non_query(connection,command,NULL);
          gda_command_free(command);
        
          gda_connection_rollback_transaction(connection,transaction_two);
          g_object_unref(transaction_one);
        
          execute_sql_command(connection,"SELECT * FROM accounts");
        }
        </programlisting>
        <calloutlist>
          <callout arearefs="transactions-1">
            <para>
              Creates first transaction.
            </para>
          </callout>
          <callout arearefs="transactions-1a">
            <para>
              Changes the isolation level.
            </para>
          </callout>
          <callout arearefs="transactions-2">
            <para>
              Links it to connection.
            </para>
          </callout>
          <callout arearefs="transactions-3">
            <para>
              Links command to transaction.
            </para>
          </callout>
          <callout arearefs="transactions-4">
            <para>
              Makes commit on transaction.
            </para>
          </callout>
          <callout arearefs="transactions-5">
            <para>
              Frees transaction.
            </para>
          </callout>
          <callout arearefs="transactions-6">
            <para>
              Makes rollback on second transaction.
            </para>
          </callout>
        </calloutlist>
      </programlistingco>
    </sect1><!--
    <sect1 id="batch">
      <title>Batch</title>
      
      <para>
      Batch processes are supposed to be also a simple way to manage transactions,
      but I could not work on it because it is not included in the library.
      </para>
      
    </sect1>
      -->
  </chapter>
  <chapter id="managing-errors">
    <title>Managing errors</title>
    <para>
      You can manage errors with <link
      linkend="libgda-GdaError">GdaError</link> class and obtain them with
      function <link
      linkend="gda-connection-get-errors"><emphasis>gda_connection_get_errors()
      </emphasis></link> so let's see them and an example: 
    </para>
    <para>
      Here you see the functions to manage errors:
    </para>
    <itemizedlist>
      <listitem><para>
        <link linkend="gda-error-get-description">gda_error_get_description()</link></para>
      </listitem>
      <listitem><para>
        <link linkend="gda-error-get-number">gda_error_get_number()</link></para>
      </listitem>
      <listitem><para>
        <link linkend="gda-error-get-source">gda_error_get_source()</link></para>
      </listitem>
      <listitem><para>
        <link linkend="gda-error-get-sqlstate">gda_error_get_sqlstate()</link></para>
      </listitem>
    </itemizedlist>
    <para>
      Here you can see an example of using this:
    </para>
    <programlistingco>
      <areaspec units="LINECOLUMN">
        <area id="errors-1" coords="8 1"/>
        <area id="errors-2" coords="10 1"/>
      </areaspec>
      <programlisting>
      gboolean
      get_errors (GdaConnection *connection)
      {
        GList *list;
        GList *node;
        GdaError *error;
      
        list = (GList *) gda_connection_get_errors (connection);
      
        for (node = g_list_first (list); node != NULL; node = g_list_next (node))
          {
            error = (GdaError *) node->data;
            g_print ("Error no: %d\t", gda_error_get_number (error));
            g_print ("desc: %s\t", gda_error_get_description (error));
            g_print ("source: %s\t", gda_error_get_source (error));
            g_print ("sqlstate: %s\n", gda_error_get_sqlstate (error));
          }
      }
      </programlisting>
      <calloutlist>
        <callout arearefs="errors-1">
          <para>
            Obtains errors list.
          </para>
        </callout>
        <callout arearefs="errors-2">
          <para>
            Loop for getting error information.
          </para>
        </callout>
      </calloutlist>
    </programlistingco>
  </chapter>
  <chapter id="main_example">
    <title>Full example</title>
    <programlisting>
<inlinegraphic entityref="fullexample"></inlinegraphic>
    </programlisting>
  </chapter>
  <chapter id="migration">
    <title>Some formulae for migration from old version</title>
    <sect1 id="migration-compilation">
      <title>Compiling and initialising</title>
      <para>
        To <link linkend="compiling">compile</link> you do not need to link
        with many libraries and configure directories of headers files, only
        capture the output of <emphasis>pkg-config</emphasis> as follows:
        <programlisting>
          <systemitem class="prompt">$</systemitem> <userinput> gcc -o main `pkg-config --cflags --libs libgda` main.c</userinput>
        </programlisting>
      </para>
      <para>
        Further more, you only need to include one <link
        linkend="installation-development">headers file</link> and it is:
        <programlisting>
    #include &lt;libgda/libgda.h&gt;
        </programlisting>
      </para>
      <para>
        As in the old version, you need to call <link
        linkend="gda-init"><emphasis>gda_init()</emphasis></link> to
        <link linkend="initializing">initialise</link> the library:
        <programlisting>
          gda_init ("TestGDA", "0.1", argc, argv);
        </programlisting>
      </para>
    </sect1>
    <sect1 id="migration-configuration">
      <title>Configuration and connections</title>
      <para>
        If you before created connections directly to data sources, you
        will now use a <emphasis>connections pool</emphasis> and will be
        necessary to <link linkend="installation-client">create the data
        source</link> because you create connection using the data source
        identifier.
      </para>
      <sect2 id="migration-data-sources">
        <title>Creating data sources</title>
        <para>
          You have two ways to do this, one of them is creating them using
          some <link linkend="installation-client">utility of
          &GNOMEDB;</link> or using <link
          linkend="data-sources-API-functions">API functions</link>.
          Remember the little <link
          linkend="data-sources-API-functions">bug</link>.
        </para>
        <para>
          There is no problem about calling several times to this
          function because if you save an existing data source, it
          is replaced, so it could be advisable<footnote><para>But you must think
          of security if you distribute the source code because people would see
          the passwords of your databases.</para></footnote> to save the data source
          each time you want to create the connection.
        </para>
      </sect2>
      <sect2 id="migration-connections">
        <title>Creating connections</title>
        <para>
          You can see <link linkend="connections">how to create a
          connection</link> easily in a chapter above.
        </para>
      </sect2>
    </sect1>
    <sect1 id="migration-executing-commands">
      <title>Executing commands</title>
      <sect2 id="migration-creating-commands">
        <title>Creating commands</title>
        <para>
          It can be made, more or less, as in the old version, using
          <link linkend="gda-command-new">gda_command_new()</link>, but
          now, this function needs a few parameters and, in this version,
          you do not link a command to a connection, so you execute a
          command in a connection as we'll see <link
          linkend="migration-executing-non-queries">later</link>. You
          can see how to create commands and examples about this <link
          linkend="building-commands">here</link>.
        </para>
      </sect2>
      <sect2 id="migration-executing-non-queries">
        <title>Executing <emphasis>non queries</emphasis></title>
        <para>
          <emphasis>Non queries</emphasis> are queries that do not return
          data, as insertions, deletions, and so on. The function we use is
          <link
          linkend="gda-connection-execute-non-query">gda_connection_execute_non_query
          ()</link> and returns the number of affected tuples or -1 in case
          of error. <link linkend="making-queries">Here</link> you see an
          example.
        </para>
        <para>
          It is better not to execute more than one &SQL; sentence for each
          command because the result can be unexpected.
        </para>
      </sect2>
      <sect2 id="migration-executing-normal-queries">
        <title>Executing normal queries</title>
        <para>
          A normal query is a query that return data. This is made as a
          <link linkend="libgda-GdaDataModel">data model</link>, analogous
          to <emphasis>GdaRecordset</emphasis> in the old
          version<footnote><para>Now you have a <link
          linkend="libgda-provider-recordset">GdaRecordset</link> class,
          but it is not recommended.</para></footnote>.
        </para>
        <para>
          As you can see in the following example, the function we use to
          obtain data from a &SQL; sentence is <link
          linkend="gda-connection-execute-single-command">gda_connection_execute_single_command
          ()</link> and needs the parameters of <link
          linkend="migration-executing-non-queries">non queries</link>. The
          difference is that now the function returns the <link
          linkend="libgda-GdaDataModel">data model</link> or
          <emphasis>NULL</emphasis> in case of error.
        </para>
        <para>
          As in the case of <link
          linkend="gda-connection-execute-non-query">non queries</link>, you
          must not use several semicolon-separated sentences, because you
          have a special function to do this<footnote><para><link
          linkend="gda-connection-execute-command">gda_connection_execute_command
          ()</link></para></footnote>, but it is not recommended.
        </para>
      </sect2>
    </sect1>
    <sect1>
      <title>Managing data</title>
      <para>
        As we have said before, data is obtained as <link
        linkend="libgda-GdaDataModel">data models</link>. We can consider
        it as a representation of the table.
      </para>
      <para>
        We can access the table at <link
        linkend="data-model-row-access">row level</link> or <link
        linkend="data-model-table-access">table level</link>. We will focus
        on <link linkend="data-model-row-access">row level</link> because
        it is the most similar to the old version.
      </para>
      <para>
        As you can see in the <link
        linkend="data-model-row-access">example</link>, the access is made
        with the <emphasis>C</emphasis> style using a
        <literal>for</literal> to obtain data from rows and columns.
      </para>
      <para>
        We talk about <link linkend="data-model-table-access">table
        access</link> only saying that the access is made in a very similar
        way. The only difference is that <link
        linkend="gda-data-model-get-value-at">gda_data_model_get_value_at
        ()</link> returns a <literal>const</literal> and we have not to
        free it.
      </para>
      <sect2>
        <title>Something important about data models</title>
        <para>
          As you can see viewing <link
          linkend="libgda-GdaDataModel">GdaDataModel</link> class, it has
          not a <link linkend="data-model-free">free</link> method, so we
          have to free it using <literal>g_object_unref</literal>.
        </para>
        <para>
          Theoretically, you could modify data models and dump changes over
          the database, but it is not recommended because you might make
          changes using &SQL;, so we consider data models not to be
          modifiable.
        </para>
      </sect2>
      <sect2>
        <title>Accessing directly to columns</title>
        <para>
          There is not exist a function to access columns directly using
          the column name, but you can obtain its index using <link
          linkend="gda-data-model-get-column-position">gda_data_model_get_column_position
          ()</link>, as you can see in this example:
          <programlisting>
          value=gda_row_get_value(row,
              gda_data_model_get_column_position(data_model,"id_product"));
          </programlisting>
        </para>
      </sect2>
    </sect1>
    <sect1>
      <title>Managing errors</title>
      <para>
        There is a function very similar to the last version and you can
        see a very clear <link linkend="managing-errors">example</link> in
        the <link linkend="managing-errors">Managing errors section</link>.
      </para>
    </sect1>
    <sect1>
      <title>Managing transactions</title>
      <para>
        In the old version, to manage transactions was more simple but less
        powerful. In the new version it is supposed that we can launch
        several transactions over the same connection but some database
        drivers, as	&PGSQL;, do not implement it, so we do not recommend
        it. If you want to launch several transactions, you must open
        several connections, but you can do it over the same
        <emphasis>pool</emphasis>. You can see a clear <link
        linkend="transactions">example</link> in the <link
        linkend="transactions">Transactions section</link>.
      </para>
    </sect1>
  </chapter>
  <chapter id="libgda-api">
    <title>Client API Reference</title>
    <para>
      The following sections describe the API available for &GDA; applications.
    </para>
    &libgda-init;
    &libgda-blob;
    &libgda-client;
    &libgda-command;
    &libgda-config;
    &libgda-connection;
    &libgda-data-model-array;
    &libgda-data-model-hash;
    &libgda-data-model-list;
    &libgda-data-model;
    &libgda-error;
    &libgda-export;
    &libgda-field;
    &libgda-log;
    &libgda-parameter;
    &libgda-quark-list;
    &libgda-row;
    &libgda-select;
    &libgda-table;
    &libgda-transaction;
    &libgda-util;
    &libgda-value;
    &libgda-xml-connection;
    &libgda-xml-database;
    &libgda-xml-document;
  </chapter>

  <chapter id="libgda-providers">
    <title>GDA Providers</title>
    <sect1 id="libgda-provider-introduction">
    <title>Introduction</title>
    <para>
       For each different data source supported by &LIBGDA; there must be a
       GObject that implements the virtual methods defined in &GDASERVERPROVIDER;
       class.
    </para>
    <para>
       Providers must also create their own object to implement the virtual
       methods defined in &GDADATAMODEL; or one of
       its subclasses (currently &GDADATAMODELARRAY; and &GDADATAMODELHASH;) 
       to support recordsets.
    </para>
    <para>
      Since &LIBGDA; itself is developed in the C language, and that most
      providers are also implemented in that language, the &LIBGDA; library
      itself contains a set of helper classes and functions to guide you
      in the addition of a new provider to the GDA framework.
    </para>
    </sect1>
    <sect1 id="libgda-provider-class">
      <title>The GdaServerProvider class</title>
      <para>
	The &GDASERVERPROVIDER; is the class you should implement for adding
	a new provider. This class is just a typical GObject-based class,
	with a set of virtual methods, that are the ones that you must
	implement. These virtual methods are declared in the class structure,
	in the <filename>gda-server-provider.h</filename> file. They are
	explained in detail in the following subsections.
      </para>
      <sect2 id="libgda-provider-open-connection">
	<title>open_connection</title>
	   <para>
	   Sets up the connection to the database back-end using the parameters
	   received as arguments and returns a boolean TRUE if the connection
	   is successfully established, otherwise FALSE.
	</para>
      </sect2>
	<sect2 id="libgda-provider-close-connection">
	<title>close_connection</title>
	<para>
	  Frees the resources allocated for the connection and returns TRUE
	  if everything is ok
	</para>
      </sect2>
      <sect2 id="libgda-provider-get-database">
	<title>get_database</title>
	<para>
	  Returns the name of the currently open database for a given
	  connection.
	</para>
      </sect2>
      <sect2 id="libgda-provider-change-database">
	<title>change_database</title>
	<para>
	  Change the database being used in the active connection.
	</para>
      </sect2>
      <sect2 id="libgda-provider-create-database">
	<title>create_database</title>
	<para>
	  Creates a new database whose name is received in a parameter.	
	</para>
      </sect2>
      <sect2 id="libgda-provider-drop-database">
	<title>drop_database</title>
	<para>
	  Drops an existing database whose name is received in a parameter.
	</para>
      </sect2>
      <sect2 id="libgda-provider-execute-command">
	<title>execute_command</title>
	<para>
	  Executes a command and returns a GList of &GDADATAMODEL; with the
	  results.
	</para>
      </sect2>
      <sect2 id="libgda-provider-begin-transaction">
	<title>begin_transaction</title>
	<para>
	  Initiates a transaction if the DB back-end supports transactions.
	</para>
      </sect2>
      <sect2 id="libgda-provider-commit-transaction">
	<title>commit_transaction</title>
	<para>
	  Commits a transaction if the DB back-end supports transactions.
	</para>
      </sect2>
      <sect2 id="libgda-provider-rollback-transaction">
	<title>rollback_transaction</title>
	<para>
	  Rollback a transaction if the DB back-end supports transactions.
	</para>
      </sect2>
      <sect2 id="libgda-provider-supports">
	<title>supports</title>
	<para>
	  Tests if a given feature is supported by the provider and the
	  DB back-end. You can view the list of features in <filename>
	  gda-connection.h</filename>, enumeration GdaConnectionFeature.
	</para>
      </sect2>
      <sect2 id="libgda-provider-get-schema">
	<title>get_schema</title>
	<para>
	  Returns a &GDADATAMODEL; with the schema information requested.
	  You can view the list of features in <filename>
	  gda-connection.h</filename>, enumeration GdaConnectionSchema.
	  This schema information is what describes the objects in the
	  database, and is the way applications can manage the structure
	  of several database systems without knowing anything about
	  their specific way of retrieving this information.
	</para>
	<para>
	  The <function>get_schema</function> virtual method gets a
	  <type>GdaConnectionSchema</type> argument, which describes
	  the kind of schema the client making the call is interested
	  in, along with a <type>GdaParameterList</type> argument,
	  which contains the list of arguments sent by the user to
	  explicitly provide more information for the search.
	</para>
	<para>
	  The information to be returned for each schema, along with
	  the supported parameters, is described in the following table.
	</para>
	<table frame="all">
	  <title>Standard Schema and supported parameters</title>
	  <tgroup cols="4" colsep="1" rowsep="1" align="justify">
	    <colspec colname="c1"/>
	    <colspec colname="c2"/>
	    <colspec colname="c3"/>
	    <colspec colname="c4"/>
	    <thead>
	      <row>
		<entry>Object type</entry>
		<entry>GDA identifier</entry>
		<entry>Supported Parameters</entry>
		<entry>Returned fields</entry>
	      </row>
	    </thead>
	    <tbody>
	      <row>
		<entry>Databases</entry>
		<entry><parameter>GDA_CONNECTION_SCHEMA_DATABASES</parameter></entry>
		<entry></entry>
		<entry>name</entry>
	      </row>
	      <row>
		<entry>Schemas (also namespaces), a feature supported by Postgres which allows to
                       define multiple domains within a single database</entry>
		<entry><parameter>GDA_CONNECTION_SCHEMA_NAMESPACES</parameter></entry>
		<entry></entry>
		<entry>name</entry>
	      </row>
	      <row>
		<entry>Tables</entry>
		<entry><parameter>GDA_CONNECTION_SCHEMA_TABLES</parameter></entry>
		<entry>"name" (name of table, optional)</entry>
		<entry>name, owner, comments, SQL definition</entry>
	      </row>
	      <row>
		<entry>Tables' parents</entry>
		<entry><parameter>GDA_CONNECTION_SCHEMA_PARENT_TABLES</parameter></entry>
		<entry>"name" (name of table, optional)</entry>
		<entry>name, order of inheritance</entry>
	      </row>
	      <row>
		<entry>Views</entry>
		<entry><parameter>GDA_CONNECTION_SCHEMA_VIEWS</parameter></entry>
		<entry>"name" (name of view, optional)</entry>
		<entry>name, owner, comments, SQL definition</entry>
	      </row>
	      <row>
		<entry>Table (or view) fields</entry>
		<entry><parameter>GDA_CONNECTION_SCHEMA_FIELDS</parameter></entry>
		<entry>"name" (name of table (or view), required)</entry>
		<entry>name, type, size, scale, not null?, primary key?, unique index?, references, default value</entry>
	      </row>
	      <row>
		<entry>Sequences</entry>
		<entry><parameter>GDA_CONNECTION_SCHEMA_SEQUENCES</parameter></entry>
		<entry>"name" (name of sequence, optional)</entry>
		<entry>name, owner, comments, SQL definition</entry>
	      </row>
	      <row>
		<entry>Procedures</entry>
		<entry><parameter>GDA_CONNECTION_SCHEMA_PROCEDURES</parameter></entry>
		<entry>"name" (name of procedure, optional)</entry>
		<entry>name, unique id, owner, comments, return type, number of arguments, arguments types 
		       (arguments types in the order, separated by spaces) and SQL definition.
		       For the arguments where any type is accepted, '-' is returned as type.</entry>
	      </row>
	      <row>
		<entry>Aggregates</entry>
		<entry><parameter>GDA_CONNECTION_SCHEMA_AGGREGATES</parameter></entry>
		<entry>"name" (name of aggregate, optional)</entry>
		<entry>name, unique id, owner, comments, return type, argument type, SQL definition.
		       If the argument can be of any type, then '-' is returned as type.</entry>
	      </row>
	      <row>
		<entry>Types</entry>
		<entry><parameter>GDA_CONNECTION_SCHEMA_TYPES</parameter></entry>
		<entry>"name" (name of type, optional)</entry>
		<entry>name, owner, comments, GDA type</entry>
	      </row>
	    </tbody>
	  </tgroup>
	</table>
      </sect2>
    </sect1>
    <sect1 id="libgda-provider-recordset">
      <title>The recordset class</title>
      <para>
	You have to extend one of &GDADATAMODEL;, &GDADATAMODELARRAY; or
	&GDADATAMODELHASH;. The easiest to extend are the last two. They both
	derive from &GDADATAMODEL;.
      </para>
      <para>
	Here is the list of methods that you have to override. If you use
	&GDADATAMODELHASH;, you don't need to override 
	append_row.
      </para>
      <itemizedlist>
	<listitem>
	  <para>get_n_rows</para>
	  <para>
	    Returns the number of rows in the data model. If the provider
	    can know in advance the number of rows the database server has
	    returned, this function should just return that, and not
	    retrieve any data. On the other hand, if it can't it should
	    either retrieve all data, or move to the last record in the
	    recordset and retrieve the row number, if the underlying
	    data source allows it.
	  </para>
	</listitem>
	<listitem>
	  <para>get_n_columns</para>
	  <para>
	    Returns the number of columns in the data model.
	  </para>
	</listitem>
	<listitem>
	  <para>describe_column</para>
	  <para>
	    Returns information about a given column, in the form of
	    a <link linkend="GdaFieldAttributes">GdaFieldAttributes</link>.
	  </para>
	</listitem>
	<listitem>
	  <para>get_row</para>
	  <para>
	    Retrieves a row from the data model. This function is very important
	    for the implementation of editable data models. What this function
	    returns is a <link linkend="GdaRow">GdaRow</link>, which providers
	    should uniquely identify (via <link linkend="gda-row-set-id">gda_row_set_id</link>).
	    This is needed so that later on, client applications can use the same
	    <link linkend="GdaRow">GdaRow</link> returned by this method in
	    the <function>update_row</function> and <function>remove_row</function>
	    methods.
	  </para>
	</listitem>
	<listitem>
	  <para>get_value_at</para>
	  <para>
	    Returns the value stored in a given cell of the data model.
	  </para>
	</listitem>
	<listitem>
	  <para>is_editable</para>
	  <para>
	    Checks whether the data model can be modified or not. If the provider
	    supports the edition of data models, it should return TRUE in this
	    function. If it doesn't (for instance, because it can't uniquely identify
	    rows in the data model), it should return FALSE.
	  </para>
	  <para>
	    Before a data model can be edited, client applications must call the
	    <link linkend="gda-data-model-begin-edit">gda_data_model_begin_edit</link>
	    function, which emits the "begin_edit" signal on the
	    <link linkend="GdaDataModel">GdaDataModel</link> class. So, providers
	    should connect to this signal to be informed when the data model
	    starts being editing. In the callback connected to that signal,
	    it should start a transaction, for instance.
	  </para>
	  <para>
	    In a similar way, there are 2 other signals that provider's data model
	    implementations should pay attention to. Those are "end_edit" and
	    "cancel_edit". In "end_edit", if all went ok, providers should
	    COMMIT the transaction started in "begin_edit". In "cancel_edit",
	    a ROLLBACK should be made.
	  </para>
	</listitem>
	<listitem>
	  <para>append_row</para>
	  <para>
	    Appends a row to the data model. Usually, this means, in the provider,
	    executing an INSERT SQL command on the table being read by the
	    data model.
	  </para>
	</listitem>
	<listitem>
	  <para>update_row</para>
	  <para>
	    Updates an existing row in the data model. The row should have been
	    uniquely identified in the provider code, as explained for the
	    get_row method.
	  </para>
	</listitem>
	<listitem>
	  <para>remove_row</para>
	  <para>
	    Removes a row from the data model. Usually, this means, in the provider,
	    executing a DELETE SQL command on the table being read by the data model.
	    The row should have been
	    uniquely identified in the provider code, as explained for the
	    get_row method.
	  </para>
	</listitem>
      </itemizedlist>
    </sect1>
    <sect1 id="libgda-server-provider-details">
      <title>Details</title>
      &libgda-server-provider;
    </sect1>
  </chapter>

  <chapter id="libgda-xql">
    <title>XML Queries</title>
    <para>
    </para>
    &libgda-xql-atom;
    &libgda-xql-bin;
    &libgda-xql-column;
    &libgda-xql-const;
    &libgda-xql-delete;
    &libgda-xql-dml;
    &libgda-xql-dual;
    &libgda-xql-field;
    &libgda-xql-func;
    &libgda-xql-insert;
    &libgda-xql-item;
    &libgda-xql-join;
    &libgda-xql-list;
    &libgda-xql-query;
    &libgda-xql-select;
    &libgda-xql-stack;
    &libgda-xql-target;
    &libgda-xql-update;
    &libgda-xql-utils;
    &libgda-xql-value;
    &libgda-xql-valueref;
  </chapter>

  <chapter id="libgda-reports">
    <title>&GDA; Report Engine</title>
    <para>
      libgda includes a built-in reporting engine which allows applications to easily
      create, manage and run custom reports.
    </para>
    &libgda-report-types;
    &libgda-report-document;
    &libgda-report-item;
    &libgda-report-item-detail;
    &libgda-report-item-label;
    &libgda-report-item-pagefooter;
    &libgda-report-item-pageheader;
    &libgda-report-item-repfield;
    &libgda-report-item-report;
    &libgda-report-item-reportfooter;
    &libgda-report-item-reportheader;
    &libgda-report-item-sqlquery;
    &libgda-report-result;
    &libgda-report-valid;
  </chapter>
  
  &fdl-appendix;
</book>

