CTWave Query Functions

Name

CTWave Query Functions -- CTWave Query object management functions.

Synopsis


#include ctwave/ctwave-query.h


struct      CTWaveQuery;

void        ctwave_query_start              ();
void        ctwave_query_stop               ();
CTWaveQuery* ctwave_query_new               (const gchar *name);
void        ctwave_query_del                (CTWaveQuery *query);
WaveResult  ctwave_query_prepare            (CTWaveQuery *query,
                                             gchar *query_text,
                                             gboolean use_as_is);
WaveResult  ctwave_query_open               (CTWaveQuery *query,
                                             gchar *query_text,
                                             ...);
gboolean    ctwave_query_sfetch             (CTWaveQuery *query);
gboolean    ctwave_query_fetch              (CTWaveQuery *query,
                                             gchar *format,
                                             ...);
WaveResult  ctwave_query_read               (CTWaveQuery *query,
                                             gchar *format,
                                             ...);
WaveResult  ctwave_query_close              (CTWaveQuery *query,
                                             gboolean ignore_error);
WaveResult  ctwave_query_drop               (CTWaveQuery *query,
                                             gboolean ignore_error);
WaveResult  ctwave_query_execute            (CTWaveQuery *query,
                                             gchar *query_text,
                                             ...);
WaveResult  ctwave_query_static_execute     (CTWaveQuery *query,
                                             gchar *queryText);

Description

These functions initiate, execute and retrieve data.

Details

struct CTWaveQuery

struct CTWaveQuery {
  WaveQuery     *wquery;
  CTWaveCommand *cmd;
  GList         *blobs;
  gint           flags;
  gint           bindings;
  gint           output;
  gchar          cursor_name[CTWAVE_MAX_QUERY_NAME];
  WaveDbSqlDa   *desc;
  gint           binded;
};

Use internals at your own risk.


ctwave_query_start ()

void        ctwave_query_start              ();

Creates the initial stack for caching queries. Should be called once and before any query operations are executed.


ctwave_query_stop ()

void        ctwave_query_stop               ();

Cleans up the query caching stack. Should be called once and after all query operations are executed.


ctwave_query_new ()

CTWaveQuery* ctwave_query_new               (const gchar *name);

Creates a new query object. The name is used to cache this object.

name: Query name, can be NULL.
Returns : CTWave Query Object.


ctwave_query_del ()

void        ctwave_query_del                (CTWaveQuery *query);

Destroys the query object.

query: CTWave Query Object.


ctwave_query_prepare ()

WaveResult  ctwave_query_prepare            (CTWaveQuery *query,
                                             gchar *query_text,
                                             gboolean use_as_is);

Prepares a query. The query text should contain the parameters in the form of "%type". For example: "select name from customer where id = %d". If no parameters are used then set use_as_is TRUE.

query: CTWave Query Object.
query_text: Query text, ie. "select blah from blah".
use_as_is: Pass TRUE if no parameters are used.
Returns : WAVE_OK or WAVE_FAIL.


ctwave_query_open ()

WaveResult  ctwave_query_open               (CTWaveQuery *query,
                                             gchar *query_text,
                                             ...);

Opens the specified query. Query text can contain the text of the query with format specifiers, ie. "%s" or null if ctwave_query_prepare was used. The variables should be listed next.

For example:

ctwave_query_prepare(query, "select name from persons where dept = %s",FALSE) ctwave_query_open(query,NULL,"Sales")

Or

ctwave_query_open(query,"select name from persons where dept = %s","SALES")

query: CTWave Query Object.
query_text: Query text or null if prepare was used.
...: Parameter variables.
Returns : WAVE_OK or WAVE_FAIL.


ctwave_query_sfetch ()

gboolean    ctwave_query_sfetch             (CTWaveQuery *query);

Performs a fetch. The function ctwave_query_read should be called to process the data. Returns TRUE if data was fetched.

query: CTWave Query Object.
Returns : TRUE or FALSE.


ctwave_query_fetch ()

gboolean    ctwave_query_fetch              (CTWaveQuery *query,
                                             gchar *format,
                                             ...);

Performs a fetch and then a read filling the passed variables based on the format. Returns TRUE if data was read.

The format should be one of three forms.

1) %[type](name) -- Reads the field name into the variable of type type

2) %[type]#field_no -- Reads the field_noth field of the selected row (counting from 0) into the variable of type type

3) %[type] -- Read the field that follows the field previously read (or read the first field if none was previously read).

All three methods can be combined in a single read. For Example:

"select name, birthday, phone from person"

ctwave_query_fetch(query,"%s(name)%s(birthday)%s(phone),s1,s2,s3)

The following format strings will do the same as above: "%s(name)%s%s" "%s0%s%s".

query: CTWave Query Object.
format: Format string, see above.
...: Variables to place data.
Returns : TRUE or FALSE.


ctwave_query_read ()

WaveResult  ctwave_query_read               (CTWaveQuery *query,
                                             gchar *format,
                                             ...);

Performs a read filling the passed variables based on the format.

The format should be one of three forms.

1) %[type](name) -- Reads the field name; into the variable of type type;

2) %[type]#field_no -- Reads the field_noth field of the selected row (counting from 0) into the variable of type type

3) %[type] -- Read the field that follows the field previously read (or read the first field if none was previously read).

All three methods can be combined in a single read. For Example:

"select name, birthday, phone from person"

ctwave_query_read(query,"%s(name)%s(birthday)%s(phone),s1,s2,s3)

The following format strings will do the same as above: "%s(name)%s%s" "%s0%s%s".

query: CTWave Query Object.
format: Format string, see above.
...: Variables to place data.
Returns : WAVE_OK or WAVE_FAIL.


ctwave_query_close ()

WaveResult  ctwave_query_close              (CTWaveQuery *query,
                                             gboolean ignore_error);

query: 
ignore_error: 
Returns : 


ctwave_query_drop ()

WaveResult  ctwave_query_drop               (CTWaveQuery *query,
                                             gboolean ignore_error);

query: 
ignore_error: 
Returns : 


ctwave_query_execute ()

WaveResult  ctwave_query_execute            (CTWaveQuery *query,
                                             gchar *query_text,
                                             ...);

Executes the specified query. Query text can contain the text of the query with format specifiers, ie. "%s" or null if ctwave_query_prepare was used. The variables should be listed next.

For example:

ctwave_query_prepare(query, "update person set type = "S" where dept = %s",FALSE) ctwave_query_execute(query,NULL,"Sales")

Or

ctwave_query_open(query,"update person set type = "S" where dept = %s","SALES")

query: CTWave Query Object.
query_text: Query text or null if prepare was used.
...: Parameter variables.
Returns : WAVE_OK or WAVE_FAIL.


ctwave_query_static_execute ()

WaveResult  ctwave_query_static_execute     (CTWaveQuery *query,
                                             gchar *queryText);

query: 
queryText: 
Returns :