/usr/share/gtk-doc/html/libgda-5.0/ch12s07.html is in libgda-5.0-doc 5.2.4-9.
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 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Get the last inserted row: 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="howto.html" title="HOWTO for common tasks">
<link rel="prev" href="howto-exec-non-select.html" title="Execute an INSERT, UPDATE or DELETE command">
<link rel="next" href="ch12s08.html" title="Execute a DDL command">
<meta name="generator" content="GTK-Doc V1.27 (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="howto.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="howto-exec-non-select.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="ch12s08.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="id-1.3.3.9"></a>Get the last inserted row</h2></div></div></div>
<p>
<span class="application">Libgda</span> allows one to get the last inserted row right after an INSERT statement has been
executed. <span class="application">Libgda</span> returns a new <a class="link" href="GdaSet.html" title="GdaSet">GdaSet</a> object (which the caller
must unref when not needed anymore) which contains named values, one for each column of the
table in which data has been inserted. To get that object, pass a place holder to the
<em class="parameter"><code>last_insert_row</code></em> of
<a class="link" href="GdaConnection.html#gda-connection-statement-execute-non-select" title="gda_connection_statement_execute_non_select ()">gda_connection_statement_execute_non_select()</a>
</p>
<p>
The following code example show how to use the returned <a class="link" href="GdaSet.html" title="GdaSet">GdaSet</a> object:
</p>
<pre class="programlisting">
GdaSet *last_row;
GdaStatement *stmt;
stmt = gda_sql_parser_parse_string (parser, "INSERT INTO mytable (name) VALUES ('joe')", NULL, NULL);
if (gda_connection_statement_execute_non_select (connection, stmt, NULL, &last_row, &error) == -1) {
g_warning ("Can't execute INSERT: %s\n",
error && error->message ? error->message : "???");
if (error)
g_error_free (error);
}
else {
if (!last_row)
g_print ("Last row not reported\n");
else {
GSList *list;
for (list = last_row->holders; list; list = list->next) {
GdaHolder *h = GDA_HOLDER (list->data);
gchar *str;
str = gda_value_stringify (gda_holder_get_value (h));
g_print ("\t%s => %s\n", gda_holder_get_id (h), str);
g_free (str);
}
g_object_unref (last_row);
}
g_object_unref (stmt);
</pre>
<p>
Which gives the following output (considering that in the example the "mytable" table has two columns: an Id
and a Name columns):
</p>
<pre class="programlisting">
+0 => 1
+1 => joe
</pre>
<p>
</p>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.27</div>
</body>
</html>
|