CTWave Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
#include ctwave/ctwave-query.h struct CTWaveQuery; void ctwave_query_start (); void ctwave_query_stop (); CTWaveQuery* ctwave_query_new (const |
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.
void ctwave_query_start (); |
Creates the initial stack for caching queries. Should be called once and before any query operations are executed.
void ctwave_query_stop (); |
Cleans up the query caching stack. Should be called once and after all query operations are executed.
CTWaveQuery* ctwave_query_new (const |
Creates a new query object. The name is used to cache this object.
name: | Query name, can be NULL. |
Returns : | CTWave Query Object. |
void ctwave_query_del (CTWaveQuery *query); |
Destroys the query object.
query: | CTWave Query Object. |
|
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. |
|
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. |
|
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. |
|
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"
"%s
query: | CTWave Query Object. |
format: | Format string, see above. |
...: | Variables to place data. |
Returns : | TRUE or FALSE. |
|
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"
"%s
query: | CTWave Query Object. |
format: | Format string, see above. |
...: | Variables to place data. |
Returns : | WAVE_OK or WAVE_FAIL. |
|
query: | |
ignore_error: | |
Returns : |
|
query: | |
ignore_error: | |
Returns : |
|
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. |
|
query: | |
queryText: | |
Returns : |