/usr/share/gtk-doc/html/libgda-5.0/howto-exec-non-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 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Execute an INSERT, UPDATE or DELETE command: 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-modify-select.html" title="Modify the result of a SELECT command">
<link rel="next" href="ch12s07.html" title="Get the last inserted row">
<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="howto.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="howto-modify-select.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="ch12s07.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="howto-exec-non-select"></a>Execute an INSERT, UPDATE or DELETE command</h2></div></div></div>
<p>
INSERT, UPDATE or DELETE are treated in the same way as the SELECT command (see the
<a class="link" href="howto-exec-select.html" title="Execute a SELECT command">HOWTO</a> about executing
a SELECT command), except that the function to execute the command is different because the returned value
is not a data model but a success/failure value.
</p>
<p>
The following codes illustrates parsing and executing an UPDATE statement:
</p>
<pre class="programlisting">
GdaSqlParser *parser;
GdaStatement *stmt;
GError *error = NULL;
parser = gda_connection_create_parser (cnc);
if (!parser) {
/* the database provider used by cnc does not implement its own parser,
* let's use a generic one */
parser = gda_sql_parser_new ();
stmt = gda_sql_parser_parse_string (parser, "UPDATE customers set name='Joe' WHERE id=123", NULL, &error);
g_object_unref (parser);
if (!stmt) {
/* there was an error while parsing */
}
else {
gint res;
res = gda_connection_statement_execute_non_select (cnc, stmt, NULL, NULL, &error);
if (res == -1) {
/* there was an error while executing the statement */
}
else if (res >= 0)
g_print ("Command Ok, %d row(s) impacted\n", res);
else
g_print ("Command Ok, number of rows impacted is not reported\n");
}
g_object_unref (stmt);
</pre>
<p>
</p>
<p>
Note that the example above includes in the SQL statement the values of the data to use in the UPDATE
(namely 'Joe' and '123'). Even though it's simple, a better practice is to use variables, as it
prevents SQL injection and avoids formatting problems. For more intormation, see the
<a class="link" href="GdaSqlParser.html#GdaSqlParser.description" title="Description">GdaSqlParser</a> object's documentation; or the section
about convenience functions
</p>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.25</div>
</body>
</html>
|