GdaCommand

Name

GdaCommand -- Command management

Synopsis



GdaCommand* gda_command_new                 (void);
void        gda_command_free                (GdaCommand *cmd);
GdaConnection* gda_command_get_connection   (GdaCommand *cmd);
void        gda_command_set_connection      (GdaCommand *cmd,
                                             GdaConnection *cnc);
gchar*      gda_command_get_text            (GdaCommand *cmd);
void        gda_command_set_text            (GdaCommand *cmd,
                                             gchar *text);
GDA_CommandType gda_command_get_cmd_type    (GdaCommand *cmd);
void        gda_command_set_cmd_type        (GdaCommand *cmd,
                                             GDA_CommandType type);
GdaRecordset* gda_command_execute           (GdaCommand *cmd,
                                             gulong *reccount,
                                             gulong flags);
void        gda_command_create_parameter    (GdaCommand *cmd,
                                             gchar *name,
                                             GDA_ParameterDirection inout,
                                             GDA_Value *value);

Description

Details

gda_command_new ()

GdaCommand* gda_command_new                 (void);

This function allocates the memory for a command object.

Returns :

a pointer to the command object


gda_command_free ()

void        gda_command_free                (GdaCommand *cmd);

This function frees the memory of command object and cuts the association with its connection object.

cmd :

The command object which should be deallocated.


gda_command_get_connection ()

GdaConnection* gda_command_get_connection   (GdaCommand *cmd);

Returns the gda_Connection object which is used by the command.

cmd :

the command object

Returns :

a pointer to the gda_Connection object


gda_command_set_connection ()

void        gda_command_set_connection      (GdaCommand *cmd,
                                             GdaConnection *cnc);

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.

cmd :

The command object

cnc :

The connection object


gda_command_get_text ()

gchar*      gda_command_get_text            (GdaCommand *cmd);

Gets the command string which is executed when the gda_command_execute() function is called.

cmd :

the GdaCommand object

Returns :

a reference to the command string.


gda_command_set_text ()

void        gda_command_set_text            (GdaCommand *cmd,
                                             gchar *text);

Sets the command which is executed when the gda_command_execute() function is called.

cmd :

the GdaCommand object

text :

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.


gda_command_get_cmd_type ()

GDA_CommandType gda_command_get_cmd_type    (GdaCommand *cmd);

Gets the type of the command

cmd :

the GdaCommand object

Returns :

the type of the command


gda_command_set_cmd_type ()

void        gda_command_set_cmd_type        (GdaCommand *cmd,
                                             GDA_CommandType type);

Sets the command which is executed when the gda_command_execute() function is called.

cmd :

the GdaCommand object

type :

the type of the command. See the provider specification which command type is understood and the semantics of the different types.


gda_command_execute ()

GdaRecordset* gda_command_execute           (GdaCommand *cmd,
                                             gulong *reccount,
                                             gulong flags);

This function executes the command which has been set with gda_command_set_text(). It returns a GdaRecordset 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.

cmd :

the command object

reccount :

a pointer to a gulong variable. In this variable the number of affected records is stored.

flags :

flags to categorize the command.

Returns :

a pointer to a recordset or a NULL pointer if there was an error.


gda_command_create_parameter ()

void        gda_command_create_parameter    (GdaCommand *cmd,
                                             gchar *name,
                                             GDA_ParameterDirection inout,
                                             GDA_Value *value);

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).

The inout parameter defines if the value parameter is used to pass a value to the statement or to receive a value. In the exampel abov the input parameter will have a value of PARAM_IN. The value PARAM_OUT is used for output parameters when the command executes a precoedure.

value 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 gda_command_execute() function is called and the inout parameter is either PARAM_IN or PARAM_INOUT. If the inoput parameter is PARAM_OUT, memory is allocated by the library and the user must free it using CORBA_free().

IMPORTANT: use the CORBA functions to allocate the memory for the value parameter if it's not a simple data type (integer, float, ...)

cmd :

the command object

name :

the name of the parameter

inout :

direction of the parameter

value :

value of the parameter