File: migration-executing-commands.html

package info (click to toggle)
libgda2 1.2.4-1.2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 13,724 kB
  • ctags: 6,979
  • sloc: ansic: 47,166; xml: 19,896; sh: 8,797; makefile: 863; yacc: 202; lex: 129; cpp: 73
file content (102 lines) | stat: -rw-r--r-- 7,062 bytes parent folder | download
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Executing commands</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<link rel="start" href="index.html" title="GNOME Data Access manual">
<link rel="up" href="migration.html" title="Some formulae for migration from old version">
<link rel="prev" href="migration-configuration.html" title="Configuration and connections">
<link rel="next" href="ch09s04.html" title="Managing data">
<meta name="generator" content="GTK-Doc V1.10 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="introduction.html" title="Introduction">
<link rel="chapter" href="architecture.html" title="libgda architecture">
<link rel="chapter" href="installation.html" title="Installation">
<link rel="chapter" href="connecting.html" title="Beginning">
<link rel="chapter" href="processing-queries.html" title="Processing queries">
<link rel="chapter" href="ch06.html" title="Transactions and batch processes">
<link rel="chapter" href="managing-errors.html" title="Managing errors">
<link rel="chapter" href="main_example.html" title="Full example">
<link rel="chapter" href="migration.html" title="Some formulae for migration from old version">
<link rel="chapter" href="libgda-api.html" title="Client API Reference">
<link rel="chapter" href="libgda-providers.html" title="GDA Providers">
<link rel="chapter" href="libgda-xql.html" title="XML Queries">
<link rel="chapter" href="libgda-reports.html" title="GDA Report Engine">
<link rel="appendix" href="fdl.html" title="Appendix A. GNU Free Documentation License">
</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="2"><tr valign="middle">
<td><a accesskey="p" href="migration-configuration.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="migration.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GNOME Data Access manual</th>
<td><a accesskey="n" href="ch09s04.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="migration-executing-commands"></a>Executing commands</h2></div></div></div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="migration-creating-commands"></a>Creating commands</h3></div></div></div>
<p>
          It can be made, more or less, as in the old version, using
          <a class="link" href="libgda-gda-command.html#gda-command-new" title="gda_command_new ()">gda_command_new()</a>, but
          now, this function needs a few parameters and, in this version,
          you do not link a command to a connection, so you execute a
          command in a connection as we'll see <a class="link" href="migration-executing-commands.html#migration-executing-non-queries" title="Executing non queries">later</a>. You
          can see how to create commands and examples about this <a class="link" href="processing-queries.html#building-commands" title="Building commands">here</a>.
        </p>
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="migration-executing-non-queries"></a>Executing <span class="emphasis"><em>non queries</em></span>
</h3></div></div></div>
<p>
          <span class="emphasis"><em>Non queries</em></span> are queries that do not return
          data, as insertions, deletions, and so on. The function we use is
          <a class="link" href="libgda-GdaConnection.html#gda-connection-execute-non-query" title="gda_connection_execute_non_query ()">gda_connection_execute_non_query
          ()</a> and returns the number of affected tuples or -1 in case
          of error. <a class="link" href="processing-queries.html#making-queries" title="Making non queries">Here</a> you see an
          example.
        </p>
<p>
          It is better not to execute more than one <a href="http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?query=SQL"><span class="acronym">SQL</span></a> sentence for each
          command because the result can be unexpected.
        </p>
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="migration-executing-normal-queries"></a>Executing normal queries</h3></div></div></div>
<p>
          A normal query is a query that return data. This is made as a
          <a class="link" href="libgda-GdaDataModel.html" title="GdaDataModel">data model</a>, analogous
          to <span class="emphasis"><em>GdaRecordset</em></span> in the old
          version<sup>[<a name="id448341" href="#ftn.id448341" class="footnote">5</a>]</sup>.
        </p>
<p>
          As you can see in the following example, the function we use to
          obtain data from a <a href="http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?query=SQL"><span class="acronym">SQL</span></a> sentence is <a class="link" href="libgda-GdaConnection.html#gda-connection-execute-single-command" title="gda_connection_execute_single_command ()">gda_connection_execute_single_command
          ()</a> and needs the parameters of <a class="link" href="migration-executing-commands.html#migration-executing-non-queries" title="Executing non queries">non queries</a>. The
          difference is that now the function returns the <a class="link" href="libgda-GdaDataModel.html" title="GdaDataModel">data model</a> or
          <span class="emphasis"><em>NULL</em></span> in case of error.
        </p>
<p>
          As in the case of <a class="link" href="libgda-GdaConnection.html#gda-connection-execute-non-query" title="gda_connection_execute_non_query ()">non queries</a>, you
          must not use several semicolon-separated sentences, because you
          have a special function to do this<sup>[<a name="id448387" href="#ftn.id448387" class="footnote">6</a>]</sup>, but it is not recommended.
        </p>
</div>
<div class="footnotes">
<br><hr width="100" align="left">
<div class="footnote"><p><sup>[<a name="ftn.id448341" href="#id448341" class="para">5</a>] </sup>Now you have a <a class="link" href="libgda-provider-recordset.html" title="The recordset class">GdaRecordset</a> class,
          but it is not recommended.</p></div>
<div class="footnote"><p><sup>[<a name="ftn.id448387" href="#id448387" class="para">6</a>] </sup><a class="link" href="libgda-GdaConnection.html#gda-connection-execute-command" title="gda_connection_execute_command ()">gda_connection_execute_command
          ()</a></p></div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.10</div>
</body>
</html>