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

<refnamediv>
<refname>GdaCommand</refname><refpurpose>Command management</refpurpose>
</refnamediv>

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



<link linkend="GdaCommand">GdaCommand</link>* <link linkend="gda-command-new">gda_command_new</link>                 (void);
void        <link linkend="gda-command-free">gda_command_free</link>                (<link linkend="GdaCommand">GdaCommand</link> *cmd);
<link linkend="GdaConnection">GdaConnection</link>* <link linkend="gda-command-get-connection">gda_command_get_connection</link>   (<link linkend="GdaCommand">GdaCommand</link> *cmd);
void        <link linkend="gda-command-set-connection">gda_command_set_connection</link>      (<link linkend="GdaCommand">GdaCommand</link> *cmd,
                                             <link linkend="GdaConnection">GdaConnection</link> *cnc);
<link linkend="gchar">gchar</link>*      <link linkend="gda-command-get-text">gda_command_get_text</link>            (<link linkend="GdaCommand">GdaCommand</link> *cmd);
void        <link linkend="gda-command-set-text">gda_command_set_text</link>            (<link linkend="GdaCommand">GdaCommand</link> *cmd,
                                             <link linkend="gchar">gchar</link> *text);
<link linkend="GDA-CommandType">GDA_CommandType</link> <link linkend="gda-command-get-cmd-type">gda_command_get_cmd_type</link>    (<link linkend="GdaCommand">GdaCommand</link> *cmd);
void        <link linkend="gda-command-set-cmd-type">gda_command_set_cmd_type</link>        (<link linkend="GdaCommand">GdaCommand</link> *cmd,
                                             <link linkend="GDA-CommandType">GDA_CommandType</link> type);
<link linkend="GdaRecordset">GdaRecordset</link>* <link linkend="gda-command-execute">gda_command_execute</link>           (<link linkend="GdaCommand">GdaCommand</link> *cmd,
                                             <link linkend="gulong">gulong</link> *reccount,
                                             <link linkend="gulong">gulong</link> flags);
void        <link linkend="gda-command-create-parameter">gda_command_create_parameter</link>    (<link linkend="GdaCommand">GdaCommand</link> *cmd,
                                             <link linkend="gchar">gchar</link> *name,
                                             <link linkend="GDA-ParameterDirection">GDA_ParameterDirection</link> inout,
                                             <link linkend="GDA-Value">GDA_Value</link> *value);

</synopsis>
</refsynopsisdiv>

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

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

</refsect1>




<refsect1>
<title>Description</title>
<para>

</para>
</refsect1>

<refsect1>
<title>Details</title>
<refsect2>
<title><anchor id="gda-command-new">gda_command_new ()</title>
<programlisting><link linkend="GdaCommand">GdaCommand</link>* gda_command_new                 (void);</programlisting>
<para>
This function allocates the memory for a command 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"><emphasis>Returns</emphasis> :</entry><entry> a pointer to the command object
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-command-free">gda_command_free ()</title>
<programlisting>void        gda_command_free                (<link linkend="GdaCommand">GdaCommand</link> *cmd);</programlisting>
<para>
This function frees the memory of command object and
cuts the association with its connection 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>cmd</parameter>&nbsp;:</entry>
<entry> The command object which should be deallocated.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-command-get-connection">gda_command_get_connection ()</title>
<programlisting><link linkend="GdaConnection">GdaConnection</link>* gda_command_get_connection   (<link linkend="GdaCommand">GdaCommand</link> *cmd);</programlisting>
<para>
Returns the <link linkend="gda-Connection">gda_Connection</link> object which is used by the command.</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>cmd</parameter>&nbsp;:</entry>
<entry> the command object
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> a pointer to the <link linkend="gda-Connection">gda_Connection</link> object
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-command-set-connection">gda_command_set_connection ()</title>
<programlisting>void        gda_command_set_connection      (<link linkend="GdaCommand">GdaCommand</link> *cmd,
                                             <link linkend="GdaConnection">GdaConnection</link> *cnc);</programlisting>
<para>
Associates a connection with a command. All functions with this
command will use the connection to talk to the data source. If the
command is already associated with a connection, this association
is destroyed.</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>cmd</parameter>&nbsp;:</entry>
<entry> The command object
</entry></row>
<row><entry align="right"><parameter>cnc</parameter>&nbsp;:</entry>
<entry> The connection object
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-command-get-text">gda_command_get_text ()</title>
<programlisting><link linkend="gchar">gchar</link>*      gda_command_get_text            (<link linkend="GdaCommand">GdaCommand</link> *cmd);</programlisting>
<para>
Gets the command string which is executed when the <link linkend="gda-command-execute">gda_command_execute</link>()
function is called.</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>cmd</parameter>&nbsp;:</entry>
<entry> the <link linkend="GdaCommand">GdaCommand</link> object
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> a reference to the command string.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-command-set-text">gda_command_set_text ()</title>
<programlisting>void        gda_command_set_text            (<link linkend="GdaCommand">GdaCommand</link> *cmd,
                                             <link linkend="gchar">gchar</link> *text);</programlisting>
<para>
Sets the command which is executed when the <link linkend="gda-command-execute">gda_command_execute</link>()
function is called.</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>cmd</parameter>&nbsp;:</entry>
<entry> the <link linkend="GdaCommand">GdaCommand</link> object
</entry></row>
<row><entry align="right"><parameter>text</parameter>&nbsp;:</entry>
<entry> the command to perform. There are some special texts
which are reckognized by the servers. See the server documantation
for a list of special commands.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-command-get-cmd-type">gda_command_get_cmd_type ()</title>
<programlisting><link linkend="GDA-CommandType">GDA_CommandType</link> gda_command_get_cmd_type    (<link linkend="GdaCommand">GdaCommand</link> *cmd);</programlisting>
<para>
Gets the type of the command</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>cmd</parameter>&nbsp;:</entry>
<entry> the <link linkend="GdaCommand">GdaCommand</link> object
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> the type of the command
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-command-set-cmd-type">gda_command_set_cmd_type ()</title>
<programlisting>void        gda_command_set_cmd_type        (<link linkend="GdaCommand">GdaCommand</link> *cmd,
                                             <link linkend="GDA-CommandType">GDA_CommandType</link> type);</programlisting>
<para>
Sets the command which is executed when the <link linkend="gda-command-execute">gda_command_execute</link>()
function is called.</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>cmd</parameter>&nbsp;:</entry>
<entry> the <link linkend="GdaCommand">GdaCommand</link> object
</entry></row>
<row><entry align="right"><parameter>type</parameter>&nbsp;:</entry>
<entry> the type of the command. See the provider specification
which command type is understood and the semantics of the different 
types.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-command-execute">gda_command_execute ()</title>
<programlisting><link linkend="GdaRecordset">GdaRecordset</link>* gda_command_execute           (<link linkend="GdaCommand">GdaCommand</link> *cmd,
                                             <link linkend="gulong">gulong</link> *reccount,
                                             <link linkend="gulong">gulong</link> flags);</programlisting>
<para>
This function executes the command which has been set with
<link linkend="gda-command-set-text">gda_command_set_text</link>(). It returns a <link linkend="GdaRecordset">GdaRecordset</link> pointer which holds the
results from this query. If the command doesn't return any results, like
insert, or updaste statements in SQL, an empty result set is returnd.</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>cmd</parameter>&nbsp;:</entry>
<entry> the command object
</entry></row>
<row><entry align="right"><parameter>reccount</parameter>&nbsp;:</entry>
<entry> a pointer to a gulong variable. In this variable the number
of affected records is stored.
</entry></row>
<row><entry align="right"><parameter>flags</parameter>&nbsp;:</entry>
<entry> flags to categorize the command.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> a pointer to a recordset or a NULL pointer if there was an error.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gda-command-create-parameter">gda_command_create_parameter ()</title>
<programlisting>void        gda_command_create_parameter    (<link linkend="GdaCommand">GdaCommand</link> *cmd,
                                             <link linkend="gchar">gchar</link> *name,
                                             <link linkend="GDA-ParameterDirection">GDA_ParameterDirection</link> inout,
                                             <link linkend="GDA-Value">GDA_Value</link> *value);</programlisting>
<para>
This function creates a new parameter for the command. This is 
important if you want to use parameterized statements like
"select * from table where key = ?"
and substitute the value for key at a later time. It also comes
handy if you don't want to convert each parameter to it's string
representation (floating point values).
</para>
<para>
The <parameter>inout</parameter> parameter defines if the <parameter>value</parameter> parameter is used to
pass a value to the statement or to receive a value. In the exampel 
abov the <parameter>input</parameter> parameter will have a value of <link linkend="PARAM-IN-CAPS">PARAM_IN</link>. The value 
<link linkend="PARAM-OUT-CAPS">PARAM_OUT</link> is used for output parameters when the command executes
a precoedure.
</para>
<para>
<parameter>value</parameter> points to a GDA_Value variable (there will be helper functions
to create such varbales from the basic C types). This variable must
hold a valid value when the <link linkend="gda-command-execute">gda_command_execute</link>() function is called
and the <parameter>inout</parameter> parameter is either <link linkend="PARAM-IN-CAPS">PARAM_IN</link> or <link linkend="PARAM-INOUT-CAPS">PARAM_INOUT</link>.
If the <parameter>inoput</parameter> parameter is <link linkend="PARAM-OUT-CAPS">PARAM_OUT</link>, memory is allocated by the
library and the user must free it using <link linkend="CORBA-free">CORBA_free</link>().
</para>
<para>
IMPORTANT: use the CORBA functions to allocate the memory for the
value parameter if it's not a simple data type (integer, float, ...)</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>cmd</parameter>&nbsp;:</entry>
<entry> the command object
</entry></row>
<row><entry align="right"><parameter>name</parameter>&nbsp;:</entry>
<entry> the name of the parameter
</entry></row>
<row><entry align="right"><parameter>inout</parameter>&nbsp;:</entry>
<entry> direction of the parameter
</entry></row>
<row><entry align="right"><parameter>value</parameter>&nbsp;:</entry>
<entry> value of the parameter
</entry></row>
</tbody></tgroup></informaltable></refsect2>

</refsect1>




</refentry>
