MgWorkCore

Name

MgWorkCore -- Creates UPDATE, INSERT and DELETE queries form a SELECT query

Synopsis



#define     MG_WORK_CORE_TYPE
#define     MG_WORK_CORE                    (obj)
#define     IS_MG_WORK_CORE                 (obj)
#define     MG_WORK_CORE_CLASS              (klass)
#define     MG_WORK_CORE_NODE               (x)
struct      MgWorkCore;
struct      MgWorkCoreNode;
guint       mg_work_core_get_type           (void);
GObject*    mg_work_core_new                (MgQuery *query,
                                             MgTarget *modified);
gboolean    mg_work_core_run_select_query   (MgWorkCore *core,
                                             GError **error);
MgParameter* mg_work_core_find_param        (MgWorkCore *core,
                                             MgQfield *field);
MgWorkCoreNode* mg_work_core_find_core_node (MgWorkCore *core,
                                             MgParameter *param);

Object Hierarchy


  GObject
   +----MgBase
         +----MgWorkCore

Description

This object is used by the MgWorkForm widget to create and manage the modification queries (UPDATE, DELETE, INSERT) from a SELECT query given as argument, and an entity (a database table) to be modified, also given as argument. The SELECT query is copied and completely managed by the MgWorkCore object.

The way it works is quite complicated but it is necessary to understand a bit of it to be able to use the public attributes listed below. Basically what it does is in the following steps:

The object makes several pieces of information available as public data in its structure (they MUST NOT be modified), such as:

Details

MG_WORK_CORE_TYPE

#define MG_WORK_CORE_TYPE          (mg_work_core_get_type())


MG_WORK_CORE()

#define MG_WORK_CORE(obj)          G_TYPE_CHECK_INSTANCE_CAST (obj, mg_work_core_get_type(), MgWorkCore)

obj :


IS_MG_WORK_CORE()

#define IS_MG_WORK_CORE(obj)       G_TYPE_CHECK_INSTANCE_TYPE (obj, mg_work_core_get_type ())

obj :


MG_WORK_CORE_CLASS()

#define MG_WORK_CORE_CLASS(klass)  G_TYPE_CHECK_CLASS_CAST (klass, mg_work_core_get_type (), MgWorkCoreClass)

klass :


MG_WORK_CORE_NODE()

#define MG_WORK_CORE_NODE(x) ((MgWorkCoreNode *)x)

x :


struct MgWorkCore

struct MgWorkCore;


struct MgWorkCoreNode

struct MgWorkCoreNode {

        MgParameter *param;    /* each param in the query_select is also present in the 'work_context' and is only referenced there */
        gint         position; /* field position in query_select (and in the 'data_rs' MgResultSet) */
};

Each structure holds a pointer to a MgParameter and a position. The parameter belongs to the 'work_context' which is the MgContext used by the UPDATE, DELETE and INSERT queries to be executed. The position is the column position in the execution's result of the 'query_select' query which can be used by the parameter.


mg_work_core_get_type ()

guint       mg_work_core_get_type           (void);

Returns :


mg_work_core_new ()

GObject*    mg_work_core_new                (MgQuery *query,
                                             MgTarget *modified);

Creates a new MgWorkCore object and fills it with appropriate data

query must be a SELECT query (no union, etc selection query)

The modified target must belong to query and represent modifiable entity (a MgDbTable for example). If modified is NULL then no modification will be allowed.

query :

a MgQuery object

modified :

a MgTarget object, or NULL

Returns :

the new object


mg_work_core_run_select_query ()

gboolean    mg_work_core_run_select_query   (MgWorkCore *core,
                                             GError **error);

Runs the core->selec_query SELECT query and stores the resultset in core->data_rs

core :

a MgWorkCore object

error :

location to store error, or NULL

Returns :

TRUE if not error occured


mg_work_core_find_param ()

MgParameter* mg_work_core_find_param        (MgWorkCore *core,
                                             MgQfield *field);

Finds the MgParameter 'attached' to field. First the parameters in 'args_context' are looked for, then the ones in 'work_context'.

core :

a MgWorkCore object

field :

a MgQfield which belongs to the SELECT query given as 'query' argument to mg_work_core_new()

Returns :

the requested MgParameter, or NULL


mg_work_core_find_core_node ()

MgWorkCoreNode* mg_work_core_find_core_node (MgWorkCore *core,
                                             MgParameter *param);

Find the MgWorkCoreNode node which handles param.

core :

a MgWorkCoreNode object

param :

a MgParameter object

Returns :