/usr/share/gtk-doc/html/libgda-5.0/data-select.html is in libgda-5.0-doc 5.2.4-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Advanced GdaDataSelect usage: GNOME Data Access 5 manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="GNOME Data Access 5 manual">
<link rel="up" href="data_models.html" title="Data handling">
<link rel="prev" href="libgda-5.0-Gda-Value.html" title="A single Value">
<link rel="next" href="GdaBlobOp.html" title="Blobs">
<meta name="generator" content="GTK-Doc V1.25 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="data_models.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="libgda-5.0-Gda-Value.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="GdaBlobOp.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="data-select"></a>Advanced GdaDataSelect usage</h2></div></div></div>
<p>
Whenever a SELECT statement is successfully executed (using the <a class="link" href="GdaConnection.html" title="GdaConnection">GdaConnection</a>'s methods),
a new <a class="link" href="GdaDataSelect.html" title="GdaDataSelect">GdaDataSelect</a> object is created, which can be used as any other
<a class="link" href="GdaDataModel.html" title="GdaDataModel">GdaDataModel</a> object. However this object has some extra features which are
described in this section.
</p>
<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="data-select-rerun"></a>Automatic re-run of the SELECT statement</h3></div></div></div>
<p>
If the SELECT statement which has been executed contained some parameters, then the
<a class="link" href="GdaDataSelect.html#GdaDataSelect--auto-reset" title="The “auto-reset” property">auto-reset</a> property controls whether the
<a class="link" href="GdaDataSelect.html" title="GdaDataSelect">GdaDataSelect</a> object should re-run the SELECT statement
to have an up-to-date contents. This feature is disabled by default but can be enabled anytime.
</p>
<p>
For example the following code (errors checking omitted for readability):
</p>
<pre class="programlisting">
GdaStatement *stmt;
GdaSqlParser *parser = ...;
GdaDataModel *model;
stmt = gda_sql_parser_parse_string (parser,
"SELECT * FROM customers WHERE id <= ##theid::gint",
NULL, NULL);
gda_statement_get_parameters (stmt, &params, NULL);
gda_set_set_holder_value (params, NULL, "theid", 9);
model = gda_connection_statement_execute_select (cnc, stmt, params, NULL);
g_object_set (G_OBJECT (model), "auto-reset", TRUE, NULL);
g_object_unref (stmt);
</pre>
<p>
would create a <a class="link" href="GdaDataSelect.html" title="GdaDataSelect">GdaDataSelect</a> object (the 'model' variable) with the
following contents:
</p>
<pre class="programlisting">
id | name | default_served_by | country | city
---+----------------+-------------------+---------+-----
2 | Ed Lamton | 4 | SP | MDR
3 | Lew Bonito | 1 | FR | TLS
4 | Mark Lawrencep | | SP | MDR
9 | Greg Popoff | 2 | SP | MDR
</pre>
<p>
and with the following changes:
</p>
<pre class="programlisting">
gda_set_set_holder_value (params, NULL, "theid", 4);
</pre>
<p>
the contents of the data model will automatically be set to:
</p>
<pre class="programlisting">
id | name | default_served_by | country | city
---+----------------+-------------------+---------+-----
2 | Ed Lamton | 4 | SP | MDR
3 | Lew Bonito | 1 | FR | TLS
4 | Mark Lawrencep | | SP | MDR
</pre>
<p>
</p>
<p>
Important note: with some database providers (such as SQLite), the column's types (if not specified when the statement
is run) cannot be determined untill there is a value in the column. This means that a column's type may change
over time from the GDA_TYPE_NULL type to its correct type.
</p>
</div>
<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="data-select-empty-rs"></a>Invalid parameters</h3></div></div></div>
<p>
If the SELECT statement which has been executed contained some parameters, and if it is not possible to
give correct values to the parameters when the data model resulting from the execution of the SELECT must be
created, then the execution should fail and no data model should be created (see the
<a class="link" href="GdaConnection.html#gda-connection-statement-execute" title="gda_connection_statement_execute ()">gda_connection_statement_execute()</a>'s documentation).
However that default behaviour can be changed using the GDA_STATEMENT_MODEL_ALLOW_NOPARAM flag: the returned
data model will have no row and will automatically update its contents (re-run the SELECT statement)
when parameters are changed.
</p>
<p>
The example above can be modified as follows, note that the value of the 'theid' parameter is not set
which makes it invalid:
</p>
<pre class="programlisting">
GdaStatement *stmt;
GdaSqlParser *parser = ...;
GdaDataModel *model;
stmt = gda_sql_parser_parse_string (parser,
"SELECT * FROM customers WHERE id <= ##theid::gint",
NULL, NULL);
gda_statement_get_parameters (stmt, &params, NULL);
model = gda_connection_statement_execute_select_full (cnc, stmt, params,
GDA_STATEMENT_MODEL_ALLOW_NOPARAM,
NULL, NULL);
g_object_unref (stmt);
</pre>
<p>
The created data model contains no row, and with the following changes:
</p>
<pre class="programlisting">
gda_set_set_holder_value (params, NULL, "theid", 4);
</pre>
<p>
the contents of the data model will automatically be set to:
</p>
<pre class="programlisting">
id | name | default_served_by | country | city
---+----------------+-------------------+---------+-----
2 | Ed Lamton | 4 | SP | MDR
3 | Lew Bonito | 1 | FR | TLS
4 | Mark Lawrencep | | SP | MDR
</pre>
<p>
</p>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.25</div>
</body>
</html>
|