libgdamm Reference Documentation |
Public Member Functions | |
void | add_event (const Glib::RefPtr<ConnectionEvent>& event) |
Adds an event to the given connection. | |
Glib::RefPtr<ConnectionEvent> | add_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<ServerOperation> | 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. | |
Glib::RefPtr<SqlParser> | create_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<const MetaStore> | get_meta_store () const |
Get or initializes the Gda::MetaStore associated to cnc. | |
Glib::RefPtr<MetaStore> | get_meta_store () |
Get or initializes the Gda::MetaStore associated to cnc. | |
Glib::RefPtr<DataModel> | get_meta_store_data (ConnectionMetaType meta_type) |
Glib::RefPtr<DataModel> | get_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< const ServerProvider > | get_provider () const |
Get a pointer to the Gda::ServerProvider object used to access the database. | |
Glib::RefPtr<ServerProvider> | get_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::Object> | statement_execute (const Glib::ustring& sql, StatementModelUsage model_usage=STATEMENT_MODEL_RANDOM_ACCESS) |
Glib::RefPtr<Glib::Object> | statement_execute (const Glib::RefPtr<Statement>& stmt, StatementModelUsage model_usage=STATEMENT_MODEL_RANDOM_ACCESS) |
Glib::RefPtr<Glib::Object> | statement_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::ustring& sql) |
int | statement_execute_non_select (const Glib::RefPtr<Statement>& stmt) |
int | statement_execute_non_select (const Glib::RefPtr<Statement>& stmt, const Glib::RefPtr<Set>& params) |
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<DataModel> | statement_execute_select (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. | |
Glib::RefPtr<DataModel> | statement_execute_select (const Glib::ustring& sql, StatementModelUsage model_usage=STATEMENT_MODEL_RANDOM_ACCESS) |
Glib::RefPtr<DataModel> | statement_execute_select (const Glib::RefPtr<Statement>& stmt, StatementModelUsage model_usage=STATEMENT_MODEL_RANDOM_ACCESS) |
Glib::RefPtr<DataModel> | statement_execute_select (const Glib::RefPtr<Statement>& stmt, const Glib::RefPtr<Set>& params) |
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 (const Glib::ustring& id) |
Update the meta store information id. | |
bool | update_meta_store () |
Update the full meta store information. | |
bool | update_meta_store_data_types () |
Update the meta store information for the data types. | |
bool | update_meta_store_table (const Glib::ustring& table_name, const Glib::ustring& schema_name=Glib::ustring()) |
Update the meta store information for the table named table_name. | |
bool | update_meta_store_table_names (const Glib::ustring& schema_name=Glib::ustring()) |
Update the meta store information for the table names. | |
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<Connection> | create () |
static Glib::RefPtr<Connection> | open_from_string (const Glib::ustring& provider_name, const Glib::ustring& cnc_string, const Glib::ustring& auth_string=Glib::ustring(), ConnectionOptions options=CONNECTION_OPTIONS_NONE) |
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. |
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.
virtual Gnome::Gda::Connection::~Connection | ( | ) | [virtual] |
Gnome::Gda::Connection::Connection | ( | ) | [protected] |
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!
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.
str | A format string (see the printf(3) documentation). | |
Varargs | The arguments to insert in the error message. |
bool Gnome::Gda::Connection::add_savepoint | ( | const Glib::ustring & | name | ) |
Adds a SAVEPOINT named name.
name | Name of the savepoint to add. |
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.
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. |
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.
name | The name of the transation to start, or 0 . |
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.
name | The name of the transation to commit, or 0 . |
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.
type | The type of operation requested. | |
options | An optional list of parameters. |
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_sql_parser_new().
0
. bool Gnome::Gda::Connection::delete_savepoint | ( | const Glib::ustring & | name | ) |
Delete the SAVEPOINT named name when not used anymore.
name | Name of the savepoint to delete. |
true
if no error occurred. Glib::ustring Gnome::Gda::Connection::get_authentication | ( | ) | const |
Gets the user name used to open this connection.
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.
Glib::ustring Gnome::Gda::Connection::get_dsn | ( | ) | const |
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
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
Glib::RefPtr<const MetaStore> Gnome::Gda::Connection::get_meta_store | ( | ) | const |
Glib::RefPtr<MetaStore> Gnome::Gda::Connection::get_meta_store | ( | ) |
Glib::RefPtr<DataModel> Gnome::Gda::Connection::get_meta_store_data | ( | ConnectionMetaType | meta_type | ) |
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
meta_type | Describes which data to get. | |
filters | A GList of GdaHolders. |
ConnectionOptions Gnome::Gda::Connection::get_options | ( | ) | const |
Glib::RefPtr<const ServerProvider> Gnome::Gda::Connection::get_provider | ( | ) | const |
Get a pointer to the Gda::ServerProvider object used to access the database.
0
). Glib::RefPtr<ServerProvider> Gnome::Gda::Connection::get_provider | ( | ) |
Get a pointer to the Gda::ServerProvider object used to access the database.
0
). Glib::ustring Gnome::Gda::Connection::get_provider_name | ( | ) | const |
Get the name (identifier) of the database provider used by cnc.
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
0
. const GdaConnection* Gnome::Gda::Connection::gobj | ( | ) | const [inline] |
Provides access to the underlying C GObject.
GdaConnection* Gnome::Gda::Connection::gobj | ( | ) | [inline] |
Provides access to the underlying C 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.
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.
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 = Glib::ustring() , |
|||
ConnectionOptions | options = CONNECTION_OPTIONS_NONE | |||
) | [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: "[<provider>://][<username>[:<password>]@]<connection_params>" (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 "<provider_name>://<real cnc string>" 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).
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). |
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.
op | A Gda::ServerOperation object. |
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
bool Gnome::Gda::Connection::rollback_savepoint | ( | const Glib::ustring & | name | ) |
Rollback all the modifications made after the SAVEPOINT named name.
name | Name of the savepoint to rollback to. |
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.
name | The name of the transation to commit, or 0 . |
true
if the operation was successful, false
otherwise. Glib::SignalProxy0< void > Gnome::Gda::Connection::signal_conn_closed | ( | ) |
void on_my_conn_closed()
Glib::SignalProxy0< void > Gnome::Gda::Connection::signal_conn_opened | ( | ) |
void on_my_conn_opened()
Glib::SignalProxy0< void > Gnome::Gda::Connection::signal_conn_to_close | ( | ) |
void on_my_conn_to_close()
Glib::SignalProxy0< void > Gnome::Gda::Connection::signal_dsn_changed | ( | ) |
void on_my_dsn_changed()
Glib::SignalProxy1<void,const Glib::RefPtr<ConnectionEvent>&> Gnome::Gda::Connection::signal_error | ( | ) |
void on_my_error(const Glib::RefPtr<ConnectionEvent>& error)
Glib::SignalProxy0< void > Gnome::Gda::Connection::signal_transaction_status_changed | ( | ) |
void on_my_transaction_status_changed()
Glib::RefPtr<Glib::Object> Gnome::Gda::Connection::statement_execute | ( | const Glib::ustring & | sql, | |
StatementModelUsage | model_usage = STATEMENT_MODEL_RANDOM_ACCESS | |||
) |
Glib::RefPtr<Glib::Object> Gnome::Gda::Connection::statement_execute | ( | const Glib::RefPtr<Statement>& | stmt, | |
StatementModelUsage | model_usage = STATEMENT_MODEL_RANDOM_ACCESS | |||
) |
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>
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
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 . |
0
if an error occurred. int Gnome::Gda::Connection::statement_execute_non_select | ( | const Glib::ustring & | sql | ) |
int Gnome::Gda::Connection::statement_execute_non_select | ( | const Glib::RefPtr<Statement>& | stmt | ) |
int Gnome::Gda::Connection::statement_execute_non_select | ( | const Glib::RefPtr<Statement>& | stmt, | |
const Glib::RefPtr<Set>& | params | |||
) |
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.
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 . |
Glib::RefPtr<DataModel> Gnome::Gda::Connection::statement_execute_select | ( | 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.
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. |
0
if an error occurred. Glib::RefPtr<DataModel> Gnome::Gda::Connection::statement_execute_select | ( | const Glib::ustring & | sql, | |
StatementModelUsage | model_usage = STATEMENT_MODEL_RANDOM_ACCESS | |||
) |
Glib::RefPtr<DataModel> Gnome::Gda::Connection::statement_execute_select | ( | const Glib::RefPtr<Statement>& | stmt, | |
StatementModelUsage | model_usage = STATEMENT_MODEL_RANDOM_ACCESS | |||
) |
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.
stmt | A Gda::Statement object. | |
params | A Gda::Set object (which can be obtained using Gda::Statement::get_parameters()), or 0 . |
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).
stmt | A Gda::Statement object. |
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.
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. |
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.
feature | Feature to ask for. |
true
if the provider supports it, false
if not. bool Gnome::Gda::Connection::update_meta_store | ( | const Glib::ustring & | id | ) |
Update the meta store information id.
This can speed up the update of the meta store if you only need a specific information
id | An id for the information to update (see http://library.gnome.org/devel/libgda/unstable/information_schema.html) |
true
if no error occurred. bool Gnome::Gda::Connection::update_meta_store | ( | ) |
Update the full meta store information.
Note that this may take some time for big databases
true
if no error occurred. bool Gnome::Gda::Connection::update_meta_store_data_types | ( | ) |
Update the meta store information for the data types.
This can speed up the update of the meta store if you only need the data types.
true
if no error occurred. bool Gnome::Gda::Connection::update_meta_store_table | ( | const Glib::ustring & | table_name, | |
const Glib::ustring & | schema_name = Glib::ustring() | |||
) |
Update the meta store information for the table named table_name.
This can speed up the update of the meta store if you only need the information for a specific table
table_name | Name of the table where the information is needed | |
schema_name | Name of the schema is in, or "" to update all tables with the given name. As with update_meta_store_table_names(), specifying a non-empty schema_name speeds up the operation, just not as significantly as with update_meta_store_table_names() because the operation itself is already pretty quick. |
true
if no error occurred. bool Gnome::Gda::Connection::update_meta_store_table_names | ( | const Glib::ustring & | schema_name = Glib::ustring() |
) |
Update the meta store information for the table names.
This can speed up the update of the meta store if you only need the list of table names.
schema_name | Name of the schema whose tables to update, or "" to update all tables. For example, for postgresql this function takes a considerable amount of time when doing this. If you don't need information about internal postgresql tables, then you can speed up the process by only updating the tables for the "public" schema. Unfortunately, schema names are not common between different database systems. |
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.
from | Value to convert from. |
0
if not supported.
Glib::RefPtr<Gnome::Gda::Connection> wrap | ( | GdaConnection * | object, | |
bool | take_copy = false | |||
) | [related] |
A Glib::wrap() method for this object.
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. |