<refentry id="GdaBatch">
<refmeta>
<refentrytitle>GdaBatch</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>LIBGDA-CLIENT Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>GdaBatch</refname><refpurpose>Batch job execution</refpurpose>
</refnamediv>

<refsynopsisdiv><title>Synopsis</title>
<synopsis>



<link linkend="GdaBatch">GdaBatch</link>*   <link linkend="gda-batch-new">gda_batch_new</link>                   (void);
void        <link linkend="gda-batch-free">gda_batch_free</link>                  (<link linkend="GdaBatch">GdaBatch</link> *job);
<link linkend="gboolean">gboolean</link>    <link linkend="gda-batch-load-file">gda_batch_load_file</link>             (<link linkend="GdaBatch">GdaBatch</link> *job,
                                             const <link linkend="gchar">gchar</link> *filename,
                                             <link linkend="gboolean">gboolean</link> clean);
void        <link linkend="gda-batch-add-command">gda_batch_add_command</link>           (<link linkend="GdaBatch">GdaBatch</link> *job,
                                             const <link linkend="gchar">gchar</link> *cmd);
void        <link linkend="gda-batch-clear">gda_batch_clear</link>                 (<link linkend="GdaBatch">GdaBatch</link> *job);
<link linkend="gboolean">gboolean</link>    <link linkend="gda-batch-start">gda_batch_start</link>                 (<link linkend="GdaBatch">GdaBatch</link> *job);
void        <link linkend="gda-batch-stop">gda_batch_stop</link>                  (<link linkend="GdaBatch">GdaBatch</link> *job);
<link linkend="gboolean">gboolean</link>    <link linkend="gda-batch-is-running">gda_batch_is_running</link>            (<link linkend="GdaBatch">GdaBatch</link> *job);
<link linkend="GdaConnection">GdaConnection</link>* <link linkend="gda-batch-get-connection">gda_batch_get_connection</link>     (<link linkend="GdaBatch">GdaBatch</link> *job);
void        <link linkend="gda-batch-set-connection">gda_batch_set_connection</link>        (<link linkend="GdaBatch">GdaBatch</link> *job,
                                             <link linkend="GdaConnection">GdaConnection</link> *cnc);
<link linkend="gboolean">gboolean</link>    <link linkend="gda-batch-get-transaction-mode">gda_batch_get_transaction_mode</link>  (<link linkend="GdaBatch">GdaBatch</link> *job);
void        <link linkend="gda-batch-set-transaction-mode">gda_batch_set_transaction_mode</link>  (<link linkend="GdaBatch">GdaBatch</link> *job,
                                             <link linkend="gboolean">gboolean</link> mode);

</synopsis>
</refsynopsisdiv>

<refsect1>
<title>Object Hierarchy</title>
<synopsis>

  <link linkend="GtkObject">GtkObject</link>
   +----GdaBatch
</synopsis>

</refsect1>


<refsect1>
<title>Signal Prototypes</title>
<synopsis>

&quot;<link linkend="GdaBatch-begin-transaction">begin-transaction</link>&quot;
            void        user_function      (<link linkend="GdaBatch">GdaBatch</link> *gdabatch,
                                            <link linkend="gpointer">gpointer</link> user_data);
&quot;<link linkend="GdaBatch-commit-transaction">commit-transaction</link>&quot;
            void        user_function      (<link linkend="GdaBatch">GdaBatch</link> *gdabatch,
                                            <link linkend="gpointer">gpointer</link> user_data);
&quot;<link linkend="GdaBatch-rollback-transaction">rollback-transaction</link>&quot;
            void        user_function      (<link linkend="GdaBatch">GdaBatch</link> *gdabatch,
                                            <link linkend="gpointer">gpointer</link> user_data);
&quot;<link linkend="GdaBatch-execute-command">execute-command</link>&quot;
            void        user_function      (<link linkend="GdaBatch">GdaBatch</link> *gdabatch,
                                            <link linkend="gchar">gchar</link> *arg1,
                                            <link linkend="gpointer">gpointer</link> user_data);
</synopsis>
</refsect1>


<refsect1>
<title>Description</title>
<para>
The GdaBatch object provides a way of easily adding transactions to
your applications. It allows you to reference a set of commands as a
unique entity (a batch job).
</para>
</refsect1>

<refsect1>
<title>Details</title>
<refsect2>
<title><anchor id="gda-batch-new">gda_batch_new ()</title>
<programlisting><link linkend="GdaBatch">GdaBatch</link>*   gda_batch_new                   (void);</programlisting>
<para>
Creates a new <link linkend="GdaBatch">GdaBatch</link> object, which can be used in applications
to simulate a transaction, that is, a series of commands which will
be committed only if only all of them succeed. If any of the commands
return an error when executed, all the changes are rolled back (by
calling <link linkend="gda-connection-rollback-transaction">gda_connection_rollback_transaction</link>).
</para>
<para>
Although, this behavior is configurable. You can also use it as a way
of sending several commands to the underlying database, regardless
of the errors found in the process.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> a pointer to the new object, or NULL on error
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-batch-free">gda_batch_free ()</title>
<programlisting>void        gda_batch_free                  (<link linkend="GdaBatch">GdaBatch</link> *job);</programlisting>
<para>
Destroy the given batch job object</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>job</parameter>&nbsp;:</entry>
<entry> a <link linkend="GdaBatch">GdaBatch</link> object
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-batch-load-file">gda_batch_load_file ()</title>
<programlisting><link linkend="gboolean">gboolean</link>    gda_batch_load_file             (<link linkend="GdaBatch">GdaBatch</link> *job,
                                             const <link linkend="gchar">gchar</link> *filename,
                                             <link linkend="gboolean">gboolean</link> clean);</programlisting>
<para>
Load the given file as a set of commands into the given <parameter>job</parameter> object.
The <parameter>clean</parameter> parameter specifies whether to clean up the list of commands
before loading the given file or not.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>job</parameter>&nbsp;:</entry>
<entry> a <link linkend="GdaBatch">GdaBatch</link> object
</entry></row>
<row><entry align="right"><parameter>filename</parameter>&nbsp;:</entry>
<entry> file name
</entry></row>
<row><entry align="right"><parameter>clean</parameter>&nbsp;:</entry>
<entry> clean up
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> TRUE if successful, or FALSE on error
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-batch-add-command">gda_batch_add_command ()</title>
<programlisting>void        gda_batch_add_command           (<link linkend="GdaBatch">GdaBatch</link> *job,
                                             const <link linkend="gchar">gchar</link> *cmd);</programlisting>
<para>
Adds a command to the list of commands to be executed</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>job</parameter>&nbsp;:</entry>
<entry> a <link linkend="GdaBatch">GdaBatch</link> object
</entry></row>
<row><entry align="right"><parameter>cmd</parameter>&nbsp;:</entry>
<entry> command string
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-batch-clear">gda_batch_clear ()</title>
<programlisting>void        gda_batch_clear                 (<link linkend="GdaBatch">GdaBatch</link> *job);</programlisting>
<para>
Clears the given <link linkend="GdaBatch">GdaBatch</link> object. This means eliminating the
list of commands</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>job</parameter>&nbsp;:</entry>
<entry>


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-batch-start">gda_batch_start ()</title>
<programlisting><link linkend="gboolean">gboolean</link>    gda_batch_start                 (<link linkend="GdaBatch">GdaBatch</link> *job);</programlisting>
<para>
Start the batch job execution. This function will return when
the series of commands is completed, or when an error is found</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>job</parameter>&nbsp;:</entry>
<entry> a <link linkend="GdaBatch">GdaBatch</link> object
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> TRUE if all goes well, or FALSE on error
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-batch-stop">gda_batch_stop ()</title>
<programlisting>void        gda_batch_stop                  (<link linkend="GdaBatch">GdaBatch</link> *job);</programlisting>
<para>
Stop the execution of the given <link linkend="GdaBatch">GdaBatch</link> object. This cancels the
the transaction (discarding all changes) if the <link linkend="GdaBatch">GdaBatch</link> object
is in transaction mode</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>job</parameter>&nbsp;:</entry>
<entry> a <link linkend="GdaBatch">GdaBatch</link> object
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-batch-is-running">gda_batch_is_running ()</title>
<programlisting><link linkend="gboolean">gboolean</link>    gda_batch_is_running            (<link linkend="GdaBatch">GdaBatch</link> *job);</programlisting>
<para>
</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>job</parameter>&nbsp;:</entry>
<entry> a <link linkend="GdaBatch">GdaBatch</link> object
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-batch-get-connection">gda_batch_get_connection ()</title>
<programlisting><link linkend="GdaConnection">GdaConnection</link>* gda_batch_get_connection     (<link linkend="GdaBatch">GdaBatch</link> *job);</programlisting>
<para>
Return the <link linkend="GdaConnection">GdaConnection</link> object associated with the given
batch job</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>job</parameter>&nbsp;:</entry>
<entry> a <link linkend="GdaBatch">GdaBatch</link> object
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-batch-set-connection">gda_batch_set_connection ()</title>
<programlisting>void        gda_batch_set_connection        (<link linkend="GdaBatch">GdaBatch</link> *job,
                                             <link linkend="GdaConnection">GdaConnection</link> *cnc);</programlisting>
<para>
Associate a <link linkend="GdaConnection">GdaConnection</link> object to the given batch job</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>job</parameter>&nbsp;:</entry>
<entry> a <link linkend="GdaBatch">GdaBatch</link> object
</entry></row>
<row><entry align="right"><parameter>cnc</parameter>&nbsp;:</entry>
<entry> a <link linkend="GdaConnection">GdaConnection</link> object
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-batch-get-transaction-mode">gda_batch_get_transaction_mode ()</title>
<programlisting><link linkend="gboolean">gboolean</link>    gda_batch_get_transaction_mode  (<link linkend="GdaBatch">GdaBatch</link> *job);</programlisting>
<para>
</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>job</parameter>&nbsp;:</entry>
<entry> a <link linkend="GdaBatch">GdaBatch</link> object
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the transaction mode for the given <link linkend="GdaBatch">GdaBatch</link> object.
This mode specifies how the series of commands are treated. If
in transaction mode (TRUE), the execution is stopped whenever an
error is found, discarding all changes, whereas all data is
committed if no error is found.

On the other hand, if transaction mode is disabled, the execution
continues until the end regardless of any error found.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-batch-set-transaction-mode">gda_batch_set_transaction_mode ()</title>
<programlisting>void        gda_batch_set_transaction_mode  (<link linkend="GdaBatch">GdaBatch</link> *job,
                                             <link linkend="gboolean">gboolean</link> mode);</programlisting>
<para>
Enable/disable transaction mode for the given <link linkend="GdaBatch">GdaBatch</link>
object. Transaction mode is enabled by default</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>job</parameter>&nbsp;:</entry>
<entry> a <link linkend="GdaBatch">GdaBatch</link> object
</entry></row>
<row><entry align="right"><parameter>mode</parameter>&nbsp;:</entry>
<entry> transaction mode
</entry></row>
</tbody></tgroup></informaltable></refsect2>

</refsect1>

<refsect1>
<title>Signals</title>
<refsect2><title><anchor id="GdaBatch-begin-transaction">The &quot;begin-transaction&quot; signal</title>
<programlisting>void        user_function                  (<link linkend="GdaBatch">GdaBatch</link> *gdabatch,
                                            <link linkend="gpointer">gpointer</link> user_data);</programlisting>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>gdabatch</parameter>&nbsp;:</entry>
<entry>the object which received the signal.

</entry></row>
<row><entry align="right"><parameter>user_data</parameter>&nbsp;:</entry>
<entry>user data set when the signal handler was connected.</entry></row>
</tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="GdaBatch-commit-transaction">The &quot;commit-transaction&quot; signal</title>
<programlisting>void        user_function                  (<link linkend="GdaBatch">GdaBatch</link> *gdabatch,
                                            <link linkend="gpointer">gpointer</link> user_data);</programlisting>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>gdabatch</parameter>&nbsp;:</entry>
<entry>the object which received the signal.

</entry></row>
<row><entry align="right"><parameter>user_data</parameter>&nbsp;:</entry>
<entry>user data set when the signal handler was connected.</entry></row>
</tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="GdaBatch-rollback-transaction">The &quot;rollback-transaction&quot; signal</title>
<programlisting>void        user_function                  (<link linkend="GdaBatch">GdaBatch</link> *gdabatch,
                                            <link linkend="gpointer">gpointer</link> user_data);</programlisting>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>gdabatch</parameter>&nbsp;:</entry>
<entry>the object which received the signal.

</entry></row>
<row><entry align="right"><parameter>user_data</parameter>&nbsp;:</entry>
<entry>user data set when the signal handler was connected.</entry></row>
</tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="GdaBatch-execute-command">The &quot;execute-command&quot; signal</title>
<programlisting>void        user_function                  (<link linkend="GdaBatch">GdaBatch</link> *gdabatch,
                                            <link linkend="gchar">gchar</link> *arg1,
                                            <link linkend="gpointer">gpointer</link> user_data);</programlisting>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>gdabatch</parameter>&nbsp;:</entry>
<entry>the object which received the signal.
</entry></row>
<row><entry align="right"><parameter>arg1</parameter>&nbsp;:</entry>
<entry>

</entry></row>
<row><entry align="right"><parameter>user_data</parameter>&nbsp;:</entry>
<entry>user data set when the signal handler was connected.</entry></row>
</tbody></tgroup></informaltable></refsect2>
</refsect1>



</refentry>
