libgdamm Reference Documentation
Main Page   Namespaces   Book  

Gnome::Gda::Connection Class Reference

Manages a connection to a data source. More...

Inheritance diagram for Gnome::Gda::Connection:

Inheritance graph
[legend]

List of all members.

Public Member Functions

void add_event (const Glib::RefPtr<ConnectionEvent>& event)
 Adds an event to the given connection.
Glib::RefPtr<ConnectionEventadd_event_string (const Glib::ustring& str)
 Adds a new error to the given connection object.
bool add_savepoint (const Glib::ustring& name)
 Adds a SAVEPOINT named name.
Glib::SListHandle
<Glib::RefPtr<Glib::Object>> 
batch_execute (const Glib::RefPtr<Batch>& batch, const Glib::RefPtr<Set>& params, StatementModelUsage model_usage)
 Executes all the statements contained in batch (in the order in which they were added to batch), and Returns: a list of Object objects.
bool begin_transaction (const Glib::ustring& name, TransactionIsolation level)
 Starts a transaction on the data source, identified by the name parameter.
void clear_events_list ()
 This function lets you clear the list of Gda::ConnectionEvent's of the given connection.
void close ()
 Closes the connection to the underlying data source, but first emits the "conn_to_close" signal.
bool commit_transaction (const Glib::ustring& name)
 Commits the given transaction to the backend database.
Glib::RefPtr<ServerOperationcreate_operation (ServerOperationType type, const Glib::RefPtr<Set>& options)
 Creates a new Gda::ServerOperation object which can be modified in order to perform the type type of action.
Glib::RefPtr<SqlParsercreate_parser ()
 Creates a new parser object able to parse the SQL dialect understood by cnc.
bool delete_savepoint (const Glib::ustring& name)
 Delete the SAVEPOINT named name when not used anymore.
Glib::ustring get_authentication () const
 Gets the user name used to open this connection.
Glib::ustring get_cnc_string () const
 Gets the connection string used to open this connection.
Glib::ustring get_dsn () const
Glib::ListHandle< Glib::RefPtr
<const ConnectionEvent >> 
get_events () const
 Retrieves a list of the last errors occurred during the connection.
Glib::ListHandle< Glib::RefPtr
<ConnectionEvent >> 
get_events ()
 Retrieves a list of the last errors occurred during the connection.
Glib::RefPtr<MetaStoreget_meta_store ()
 Get or initializes the Gda::MetaStore associated to cnc.
Glib::RefPtr<DataModelget_meta_store_data (ConnectionMetaType meta_type, const Glib::ListHandle<Glib::RefPtr<Holder>>& filters)
 see gda_connection_get_meta_store_data
ConnectionOptions get_options () const
 Gets the Gda::ConnectionOptions used to open this connection.
Glib::RefPtr<ServerProviderget_provider ()
 Get a pointer to the Gda::ServerProvider object used to access the database.
Glib::ustring get_provider_name () const
 Get the name (identifier) of the database provider used by cnc.
Glib::RefPtr< const
TransactionStatus
get_transaction_status () const
 Get the status of cnc regarding transactions.
const GdaConnection* gobj () const
 Provides access to the underlying C GObject.
GdaConnection* gobj ()
 Provides access to the underlying C GObject.
GdaConnection* gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
bool is_opened () const
 Checks whether a connection is open or not.
bool open ()
 Tries to open the connection.
bool perform_operation (const Glib::RefPtr<ServerOperation>& op)
 Performs the operation described by op (which should have been created using create_operation()).
Glib::PropertyProxy_ReadOnly
<Glib::ustring
property_auth_string () const
 Authentication string to use.
Glib::PropertyProxy
<Glib::ustring
property_auth_string ()
 Authentication string to use.
Glib::PropertyProxy_ReadOnly
<Glib::ustring
property_cnc_string () const
 Connection string to use.
Glib::PropertyProxy
<Glib::ustring
property_cnc_string ()
 Connection string to use.
Glib::PropertyProxy_ReadOnly
<Glib::ustring
property_dsn () const
 DSN to use.
Glib::PropertyProxy
<Glib::ustring
property_dsn ()
 DSN to use.
Glib::PropertyProxy_ReadOnly
<Glib::RefPtr<MetaStore>> 
property_meta_store () const
 GdaMetaStore used by the connection.
Glib::PropertyProxy
<Glib::RefPtr<MetaStore>> 
property_meta_store ()
 GdaMetaStore used by the connection.
Glib::PropertyProxy_ReadOnly
<ConnectionOptions
property_options () const
 Options (connection sharing).
Glib::PropertyProxy
<ConnectionOptions
property_options ()
 Options (connection sharing).
bool rollback_savepoint (const Glib::ustring& name)
 Rollback all the modifications made after the SAVEPOINT named name.
bool rollback_transaction (const Glib::ustring& name)
 Rollbacks the given transaction.
Glib::SignalProxy0<void> signal_conn_closed ()
Glib::SignalProxy0<void> signal_conn_opened ()
Glib::SignalProxy0<void> signal_conn_to_close ()
Glib::SignalProxy0<void> signal_dsn_changed ()
Glib::SignalProxy1< void,
const Glib::RefPtr
<ConnectionEvent >&> 
signal_error ()
Glib::SignalProxy0<void> signal_transaction_status_changed ()
Glib::RefPtr<Glib::Objectstatement_execute (const Glib::RefPtr<Statement>& stmt, const Glib::RefPtr<Set>& params, StatementModelUsage model_usage, Glib::RefPtr<Set>& last_insert_row)
 Executes stmt.
int statement_execute_non_select (const Glib::RefPtr<Statement>& stmt, const Glib::RefPtr<Set>& params, Glib::RefPtr<Set>& last_insert_row)
 Executes a non-selection statement on the given connection.
Glib::RefPtr<DataModelstatement_execute_select (const Glib::RefPtr<Statement>& stmt, const Glib::RefPtr<Set>& params)
 Executes a selection command on the given connection.
Glib::RefPtr<DataModelstatement_execute_select_full (const Glib::RefPtr<Statement>& stmt, const Glib::RefPtr<Set>& params, StatementModelUsage model_usage, const Glib::ArrayHandle<GType>& col_types)
 Executes a selection command on the given connection.
bool statement_prepare (const Glib::RefPtr<Statement>& stmt)
 Ask the database accessed through the cnc connection to prepare the usage of stmt.
Glib::ustring statement_to_sql (const Glib::RefPtr<Statement>& stmt, const Glib::RefPtr<Set>& params, StatementSqlFlag flags, std::list<Glib::RefPtr<Holder>>& params_used)
 Renders stmt as an SQL statement, adapted to the SQL dialect used by cnc.
bool supports_feature (ConnectionFeature feature) const
 Asks the underlying provider for if a specific feature is supported.
bool update_meta_store (GdaMetaContext* context)
 Updates cnc's associated Gda::MetaStore.
Glib::ustring value_to_sql_string (const Value& from) const
 Produces a fully quoted and escaped string from a GValue.
virtual ~Connection ()

Static Public Member Functions

static Glib::RefPtr<Connectioncreate ()
static Glib::RefPtr<Connectionopen_from_string (const Glib::ustring& provider_name, const Glib::ustring& cnc_string, const Glib::ustring& auth_string, ConnectionOptions options)
 Opens a connection given a provider ID and a connection string.

Protected Member Functions

 Connection ()
virtual void on_conn_closed ()
virtual void on_conn_opened ()
virtual void on_conn_to_close ()
virtual void on_dsn_changed ()
virtual void on_error (const Glib::RefPtr<ConnectionEvent>& error)
virtual void on_transaction_status_changed ()

Related Functions

(Note that these are not member functions.)

Glib::RefPtr
<Gnome::Gda::Connection
wrap (GdaConnection* object, bool take_copy=false)
 A Glib::wrap() method for this object.


Detailed Description

Manages a connection to a data source.

This class offers access to all operations involving an opened connection to a database. Connection objects are obtained via the Client class.

Once obtained, applications can use a Connection to execute commands, run transactions, and get information about all objects stored in the underlying database.


Constructor& Destructor Documentation

virtual Gnome::Gda::Connection::~Connection (  )  [virtual]

Gnome::Gda::Connection::Connection (  )  [protected]


Member Function Documentation

void Gnome::Gda::Connection::add_event ( const Glib::RefPtr<ConnectionEvent>&  event  ) 

Adds an event to the given connection.

This function is usually called by providers, to inform clients of events that happened during some operation.

As soon as a provider (or a client, it does not matter) calls this function with an event object which is an error, the connection object emits the "error" signal, to which clients can connect to be informed of events.

WARNING: the reference to the event object is stolen by this function!

Parameters:
event Is stored internally, so you don't need to unref it.

Glib::RefPtr<ConnectionEvent> Gnome::Gda::Connection::add_event_string ( const Glib::ustring str  ) 

Adds a new error to the given connection object.

This is just a convenience function that simply creates a Gda::ConnectionEvent and then calls gda_server_connection_add_error.

Parameters:
str A format string (see the printf(3) documentation).
Varargs The arguments to insert in the error message.
Returns:
A new Gda::ConnectionEvent object, however the caller does not hold a reference to the returned object, and if need be the caller must call Glib::object_ref() on it.

bool Gnome::Gda::Connection::add_savepoint ( const Glib::ustring name  ) 

Adds a SAVEPOINT named name.

Parameters:
name Name of the savepoint to add.
Returns:
true if no error occurred.

Glib::SListHandle< Glib::RefPtr<Glib::Object> > Gnome::Gda::Connection::batch_execute ( const Glib::RefPtr<Batch>&  batch,
const Glib::RefPtr<Set>&  params,
StatementModelUsage  model_usage 
)

Executes all the statements contained in batch (in the order in which they were added to batch), and Returns: a list of Object objects.

Parameters:
batch A Gda::Batch object which contains all the statements to execute.
params A Gda::Set object (which can be obtained using Gda::Batch::get_parameters()), or 0.
model_usage Specifies how the returned data model(s) will be used, as a Gda::StatementModelUsage enum.
Returns:
A list of Object objects.

bool Gnome::Gda::Connection::begin_transaction ( const Glib::ustring name,
TransactionIsolation  level 
)

Starts a transaction on the data source, identified by the name parameter.

Before starting a transaction, you can check whether the underlying provider does support transactions or not by using the supports_feature() function.

Parameters:
name The name of the transation to start, or 0.
Returns:
true if the transaction was started successfully, false otherwise.

void Gnome::Gda::Connection::clear_events_list (  ) 

This function lets you clear the list of Gda::ConnectionEvent's of the given connection.

void Gnome::Gda::Connection::close (  ) 

Closes the connection to the underlying data source, but first emits the "conn_to_close" signal.

bool Gnome::Gda::Connection::commit_transaction ( const Glib::ustring name  ) 

Commits the given transaction to the backend database.

You need to call begin_transaction() first.

Parameters:
name The name of the transation to commit, or 0.
Returns:
true if the transaction was finished successfully, false otherwise.

static Glib::RefPtr<Connection> Gnome::Gda::Connection::create (  )  [static]

Glib::RefPtr<ServerOperation> Gnome::Gda::Connection::create_operation ( ServerOperationType  type,
const Glib::RefPtr<Set>&  options 
)

Creates a new Gda::ServerOperation object which can be modified in order to perform the type type of action.

It is a wrapper around the Gda::ServerProvider::create_operation() method.

Parameters:
type The type of operation requested.
options An optional list of parameters.
Returns:
A new Gda::ServerOperation object, or 0 in the connection's provider does not support the type type of operation or if an error occurred.

Glib::RefPtr<SqlParser> Gnome::Gda::Connection::create_parser (  ) 

Creates a new parser object able to parse the SQL dialect understood by cnc.

If the Gda::ServerProvider object internally used by cnc does not have its own parser, then 0 is returned, and a general SQL parser can be obtained using Gda::SqlParser::new().

Returns:
A new Gda::SqlParser object, or 0.

bool Gnome::Gda::Connection::delete_savepoint ( const Glib::ustring name  ) 

Delete the SAVEPOINT named name when not used anymore.

Parameters:
name Name of the savepoint to delete.
Returns:
true if no error occurred.

Glib::ustring Gnome::Gda::Connection::get_authentication (  )  const

Gets the user name used to open this connection.

Returns:
The user name.

Glib::ustring Gnome::Gda::Connection::get_cnc_string (  )  const

Gets the connection string used to open this connection.

The connection string is the string sent over to the underlying database provider, which describes the parameters to be used to open a connection on the underlying data source.

Returns:
The connection string used when opening the connection.

Glib::ustring Gnome::Gda::Connection::get_dsn (  )  const

Returns:
The data source name the connection object is connected to.

Glib::ListHandle<Glib::RefPtr<const ConnectionEvent>> Gnome::Gda::Connection::get_events (  )  const

Retrieves a list of the last errors occurred during the connection.

The returned list is chronologically ordered such as that the most recent event is the Gda::ConnectionEvent of the first node.

Warning: the cnc object may change the list if connection events occur

Returns:
A GList of Gda::ConnectionEvent objects (the list should not be modified).

Glib::ListHandle<Glib::RefPtr<ConnectionEvent>> Gnome::Gda::Connection::get_events (  ) 

Retrieves a list of the last errors occurred during the connection.

The returned list is chronologically ordered such as that the most recent event is the Gda::ConnectionEvent of the first node.

Warning: the cnc object may change the list if connection events occur

Returns:
A GList of Gda::ConnectionEvent objects (the list should not be modified).

Glib::RefPtr<MetaStore> Gnome::Gda::Connection::get_meta_store (  ) 

Get or initializes the Gda::MetaStore associated to cnc.

Returns:
A Gda::MetaStore object.

Glib::RefPtr<DataModel> Gnome::Gda::Connection::get_meta_store_data ( ConnectionMetaType  meta_type,
const Glib::ListHandle<Glib::RefPtr<Holder>>&  filters 
)

see gda_connection_get_meta_store_data

Parameters:
meta_type Describes which data to get.
filters A GList of GdaHolders.
Returns:
A Gda::DataModel containing the data required. The caller is responsible for freeing the returned model using Glib::object_unref().

ConnectionOptions Gnome::Gda::Connection::get_options (  )  const

Gets the Gda::ConnectionOptions used to open this connection.

Returns:
The connection options.

Glib::RefPtr<ServerProvider> Gnome::Gda::Connection::get_provider (  ) 

Get a pointer to the Gda::ServerProvider object used to access the database.

Returns:
The Gda::ServerProvider (NEVER 0).

Glib::ustring Gnome::Gda::Connection::get_provider_name (  )  const

Get the name (identifier) of the database provider used by cnc.

Returns:
A non modifiable string.

Glib::RefPtr<const TransactionStatus> Gnome::Gda::Connection::get_transaction_status (  )  const

Get the status of cnc regarding transactions.

The returned object should not be modified or destroyed; however it may be modified or destroyed by the connection itself.

If 0 is returned, then no transaction has been associated with cnc

Returns:
A Gda::TransactionStatus object, or 0.

const GdaConnection* Gnome::Gda::Connection::gobj (  )  const [inline]

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

References Glib::ValueBase::gobject_.

GdaConnection* Gnome::Gda::Connection::gobj (  )  [inline]

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

References Glib::ValueBase::gobject_.

GdaConnection* Gnome::Gda::Connection::gobj_copy (  ) 

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

bool Gnome::Gda::Connection::is_opened (  )  const

Checks whether a connection is open or not.

Returns:
true if the connection is open, false if it's not.

virtual void Gnome::Gda::Connection::on_conn_closed (  )  [protected, virtual]

virtual void Gnome::Gda::Connection::on_conn_opened (  )  [protected, virtual]

virtual void Gnome::Gda::Connection::on_conn_to_close (  )  [protected, virtual]

virtual void Gnome::Gda::Connection::on_dsn_changed (  )  [protected, virtual]

virtual void Gnome::Gda::Connection::on_error ( const Glib::RefPtr<ConnectionEvent>&  error  )  [protected, virtual]

virtual void Gnome::Gda::Connection::on_transaction_status_changed (  )  [protected, virtual]

bool Gnome::Gda::Connection::open (  ) 

Tries to open the connection.

Returns:
true if the connection is opened, and false otherwise.

static Glib::RefPtr<Connection> Gnome::Gda::Connection::open_from_string ( const Glib::ustring provider_name,
const Glib::ustring cnc_string,
const Glib::ustring auth_string,
ConnectionOptions  options 
) [static]

Opens a connection given a provider ID and a connection string.

This allows applications to open connections without having to create a data source (DSN) in the configuration. The format of cnc_string is similar to PostgreSQL and MySQL connection strings. It is a semicolumn-separated series of <key>=<value> pairs, where each key and value are encoded as per RFC 1738, see gda_rfc1738_encode() for more information.

The possible keys depend on the provider, the "gda-sql-4.0 -L" command can be used to list the actual keys for each installed database provider.

For example the connection string to open an SQLite connection to a database file named "my_data.db" in the current directory would be <constant>"DB_DIR=.;DB_NAME=my_data"</constant>.

The cnc_string string must have the following format: "[&lt;provider&gt;://][&lt;username&gt;[:&lt;password&gt;]@]&lt;connection_params&gt;" (if <username> and/or <password> are provided, and auth_string is 0, then these username and passwords will be used, and if <provider> is provided and provider_name is 0 then this provider will be used). Note that if provided, <username>, <password> and <provider> must be encoded as per RFC 1738, see gda_rfc1738_encode() for more information.

The auth_string must contain the authentication information for the server to accept the connection. It is a string containing semi-colon seperated named values, usually like "USERNAME=...;PASSWORD=..." where the ... are replaced by actual values. Note that each name and value must be encoded as per RFC 1738, see gda_rfc1738_encode() for more information.

The actual named parameters required depend on the provider being used, and that list is available as the <parameter>auth_params</parameter> member of the Gda::ProviderInfo structure for each installed provider (use Gda::Config::get_provider_info() to get it). Similarly to the format of the connection string, use the "gda-sql-4.0 -L" command to list the possible named parameters.

Additionally, it is possible to have the connection string respect the "&lt;provider_name&gt;://&lt;real cnc string&gt;" format, in which case the provider name and the real connection string will be extracted from that string (note that if provider_name is not 0 then it will still be used as the provider ID).

Parameters:
provider_name Provider ID to connect to, or 0.
cnc_string Connection string.
auth_string Authentication string, or 0.
options Options for the connection (see Gda::ConnectionOptions).
Returns:
A new Gda::Connection if connection opening was sucessfull or 0 if there was an error.

bool Gnome::Gda::Connection::perform_operation ( const Glib::RefPtr<ServerOperation>&  op  ) 

Performs the operation described by op (which should have been created using create_operation()).

It is a wrapper around the Gda::ServerProvider::perform_operation() method.

Parameters:
op A Gda::ServerOperation object.
Returns:
true if no error occurred.

Glib::PropertyProxy_ReadOnly<Glib::ustring> Gnome::Gda::Connection::property_auth_string (  )  const

Authentication string to use.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<Glib::ustring> Gnome::Gda::Connection::property_auth_string (  ) 

Authentication string to use.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<Glib::ustring> Gnome::Gda::Connection::property_cnc_string (  )  const

Connection string to use.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<Glib::ustring> Gnome::Gda::Connection::property_cnc_string (  ) 

Connection string to use.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<Glib::ustring> Gnome::Gda::Connection::property_dsn (  )  const

DSN to use.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<Glib::ustring> Gnome::Gda::Connection::property_dsn (  ) 

DSN to use.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<Glib::RefPtr<MetaStore>> Gnome::Gda::Connection::property_meta_store (  )  const

GdaMetaStore used by the connection.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<Glib::RefPtr<MetaStore>> Gnome::Gda::Connection::property_meta_store (  ) 

GdaMetaStore used by the connection.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<ConnectionOptions> Gnome::Gda::Connection::property_options (  )  const

Options (connection sharing).

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<ConnectionOptions> Gnome::Gda::Connection::property_options (  ) 

Options (connection sharing).

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

bool Gnome::Gda::Connection::rollback_savepoint ( const Glib::ustring name  ) 

Rollback all the modifications made after the SAVEPOINT named name.

Parameters:
name Name of the savepoint to rollback to.
Returns:
true if no error occurred.

bool Gnome::Gda::Connection::rollback_transaction ( const Glib::ustring name  ) 

Rollbacks the given transaction.

This means that all changes made to the underlying data source since the last call to begin_transaction() or commit_transaction() will be discarded.

Parameters:
name The name of the transation to commit, or 0.
Returns:
true if the operation was successful, false otherwise.

Glib::SignalProxy0< void > Gnome::Gda::Connection::signal_conn_closed (  ) 

Prototype:
void on_my_conn_closed()

Glib::SignalProxy0< void > Gnome::Gda::Connection::signal_conn_opened (  ) 

Prototype:
void on_my_conn_opened()

Glib::SignalProxy0< void > Gnome::Gda::Connection::signal_conn_to_close (  ) 

Prototype:
void on_my_conn_to_close()

Glib::SignalProxy0< void > Gnome::Gda::Connection::signal_dsn_changed (  ) 

Prototype:
void on_my_dsn_changed()

Glib::SignalProxy1<void,const Glib::RefPtr<ConnectionEvent>&> Gnome::Gda::Connection::signal_error (  ) 

Prototype:
void on_my_error(const Glib::RefPtr<ConnectionEvent>& error)

Glib::SignalProxy0< void > Gnome::Gda::Connection::signal_transaction_status_changed (  ) 

Prototype:
void on_my_transaction_status_changed()

Glib::RefPtr<Glib::Object> Gnome::Gda::Connection::statement_execute ( const Glib::RefPtr<Statement>&  stmt,
const Glib::RefPtr<Set>&  params,
StatementModelUsage  model_usage,
Glib::RefPtr<Set>&  last_insert_row 
)

Executes stmt.

As stmt can, by desing (and if not abused), contain only one SQL statement, the return object will either be: <itemizedlist> <listitem>a Gda::DataSelect object (which is also a Gda::DataModel) if stmt is a SELECT statement (usually a GDA_SQL_STATEMENT_SELECT, see Gda::SqlStatementType) containing the results of the SELECT. The resulting data model is by default read only, but modifications can be enabled, see the Gda::DataSelect's documentation for more information.</listitem> <listitem>a Gda::Set for any other SQL statement which correctly executed. In this case (if the provider supports it), then the Gda::Set may contain value holders named: <itemizedlist> <listitem>a (int) Gda::Holder named "IMPACTED_ROWS"</listitem> <listitem>a (GObject) Gda::Holder named "EVENT" which contains a Gda::ConnectionEvent</listitem> </itemizedlist></listitem> </itemizedlist>

If last_insert_row is not 0 and stmt is an INSERT statement, then it will contain (if the provider used by cnc supports it) a new Gda::Set object composed of value holders named "+& lt;column number& gt;" starting at column 0 which contain the actual inserted values. For example if a table is composed of an 'id' column which is auto incremented and a 'name' column then the execution of a "INSERT INTO mytable (name) VALUES ('joe')" query will return a Gda::Set with two holders: <itemizedlist> <listitem>one with the '+0' ID which may for example contain 1 (note that its "name" property should be "id")</listitem> <listitem>one with the '+1' ID which will contain 'joe' (note that its "name" property should be "name")</listitem> </itemizedlist>

Note:
If stmt is a SELECT statement which has some parameters and if is 0, then the statement can't be executed and this method will return 0.

If stmt is a SELECT statement which has some parameters and if is not 0 but contains some invalid parameters, then the statement can't be executed and this method will return 0, unless the model_usage has the GDA_STATEMENT_MODEL_ALLOW_NOPARAM flag.

If stmt is a SELECT statement which has some parameters and if is not 0 but contains some invalid parameters and if model_usage has the GDA_STATEMENT_MODEL_ALLOW_NOPARAM flag, then the returned data model will contain no row but will have all the correct columns (even though some of the columns might report as GDA_TYPE_0). In this case, if (after this method call) any of ' parameters change then the resulting data model will re-run itself, see the GdaDataSelect's auto-reset property for more information.

if model_usage does not contain the GDA_STATEMENT_MODEL_RANDOM_ACCESS or GDA_STATEMENT_MODEL_CURSOR_FORWARD flags, then the default will be to return a random access data model

Also see the provider's limitations, and the Advanced GdaDataSelect usage sections.
Parameters:
stmt A Gda::Statement object.
params A Gda::Set object (which can be obtained using Gda::Statement::get_parameters()), or 0.
model_usage In the case where stmt is a SELECT statement, specifies how the returned data model will be used.
last_insert_row A place to store a new Gda::Set object which contains the values of the last inserted row, or 0.
Returns:
A Object, or 0 if an error occurred.

int Gnome::Gda::Connection::statement_execute_non_select ( const Glib::RefPtr<Statement>&  stmt,
const Glib::RefPtr<Set>&  params,
Glib::RefPtr<Set>&  last_insert_row 
)

Executes a non-selection statement on the given connection.

The gda_execute_non_select_command() method can be easier to use if one prefers to use some SQL directly.

This function returns the number of rows affected by the execution of stmt, or -1 if an error occurred, or -2 if the connection's provider does not return the number of rows affected.

This function is just a convenience function around the statement_execute() function. See the documentation of the statement_execute() for information about the list of parameters.

See statement_execute() form more information about last_insert_row.

Parameters:
stmt A Gda::Statement object.
params A Gda::Set object (which can be obtained using Gda::Statement::get_parameters()), or 0.
last_insert_row A place to store a new Gda::Set object which contains the values of the last inserted row, or 0.
Returns:
The number of rows affected (>=0) or -1 or -2.

Glib::RefPtr<DataModel> Gnome::Gda::Connection::statement_execute_select ( const Glib::RefPtr<Statement>&  stmt,
const Glib::RefPtr<Set>&  params 
)

Executes a selection command on the given connection.

The gda_execute_select_command() method can be easier to use if one prefers to use some SQL directly.

This function returns a Gda::DataModel resulting from the SELECT statement, or 0 if an error occurred.

This function is just a convenience function around the statement_execute() function.

See the documentation of the statement_execute() for information about the list of parameters.

Parameters:
stmt A Gda::Statement object.
params A Gda::Set object (which can be obtained using Gda::Statement::get_parameters()), or 0.
Returns:
A Gda::DataModel containing the data returned by the data source, or 0 if an error occurred.

Glib::RefPtr<DataModel> Gnome::Gda::Connection::statement_execute_select_full ( const Glib::RefPtr<Statement>&  stmt,
const Glib::RefPtr<Set>&  params,
StatementModelUsage  model_usage,
const Glib::ArrayHandle< GType > &  col_types 
)

Executes a selection command on the given connection.

This function returns a Gda::DataModel resulting from the SELECT statement, or 0 if an error occurred.

This function is just a convenience function around the statement_execute() function.

See the documentation of the statement_execute() for information about the list of parameters.

Parameters:
stmt A Gda::Statement object.
params A Gda::Set object (which can be obtained using Gda::Statement::get_parameters()), or 0.
model_usage Specifies how the returned data model will be used as a Gda::StatementModelUsage enum.
col_types An array of GType to request each returned Gda::DataModel's column's GType, terminated with the G_TYPE_NONE value. Any value left to 0 will make the database provider determine the real GType. col_types can also be 0 if no column type is specified.
Returns:
A Gda::DataModel containing the data returned by the data source, or 0 if an error occurred.

bool Gnome::Gda::Connection::statement_prepare ( const Glib::RefPtr<Statement>&  stmt  ) 

Ask the database accessed through the cnc connection to prepare the usage of stmt.

This is only usefull if stmt will be used more than once (however some database providers may always prepare stamements before executing them).

This function is also usefull to make sure stmt is fully understood by the database before actually executing it.

Note however that it is also possible that statement_prepare() fails when statement_execute() does not fail (this will usually be the case with statements such as <![CDATA["SELECT* FROM ##tablename::string"]]> because database usually don't allow variables to be used in place of a table name).

Parameters:
stmt A Gda::Statement object.
Returns:
true if no error occurred.

Glib::ustring Gnome::Gda::Connection::statement_to_sql ( const Glib::RefPtr<Statement>&  stmt,
const Glib::RefPtr<Set>&  params,
StatementSqlFlag  flags,
std::list<Glib::RefPtr<Holder>>&  params_used 
)

Renders stmt as an SQL statement, adapted to the SQL dialect used by cnc.

Parameters:
stmt A Gda::Statement object.
params A Gda::Set object (which can be obtained using Gda::Statement::get_parameters()), or 0.
flags SQL rendering flags, as Gda::StatementSqlFlag OR'ed values.
params_used A place to store the list of individual Gda::Holder objects within which have been used.
Returns:
A new string, or 0 if an error occurred.

bool Gnome::Gda::Connection::supports_feature ( ConnectionFeature  feature  )  const

Asks the underlying provider for if a specific feature is supported.

Parameters:
feature Feature to ask for.
Returns:
true if the provider supports it, false if not.

bool Gnome::Gda::Connection::update_meta_store ( GdaMetaContext *  context  ) 

Updates cnc's associated Gda::MetaStore.

If context is not 0, then only the parts described by context will be updated, and if it is 0, then the complete meta store will be updated.

Parameters:
context Description of which part of cnc's associated Gda::MetaStore should be updated, or 0.
Returns:
true if no error occurred.

Glib::ustring Gnome::Gda::Connection::value_to_sql_string ( const Value from  )  const

Produces a fully quoted and escaped string from a GValue.

Parameters:
from Value to convert from.
Returns:
Escaped and quoted value or 0 if not supported.


Friends And Related Function Documentation

Glib::RefPtr<Gnome::Gda::Connection> wrap ( GdaConnection *  object,
bool  take_copy = false 
) [related]

A Glib::wrap() method for this object.

Parameters:
object The C instance.
take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns:
A C++ instance that wraps this C instance.


The documentation for this class was generated from the following file:

Generated for libgdamm by Doxygen 1.5.6 © 1997-2001