Debian Codegraph @

doc/html/pgtcl-pgexec.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <head>
5 <meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.6.0">
6 <title>pg_exec</title>
7 <meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.79">
8 <link rev="MADE" href="mailto:[email protected]">
9 <link rel="HOME" title="PostgreSQL Tcl Interface Documentation" href="index.html">
10 <link rel="UP" title="pgtcl Command Reference" href="libpgtcl-ref.html">
11 <link rel="PREVIOUS" title="pg_conndefaults" href="pgtcl-pgconndefaults.html">
12 <link rel="NEXT" title="pg_exec_prepared" href="pgtcl-pgexecprepared.html">
13 <link rel="STYLESHEET" type="text/css" href="stylesheet.css">
14 </head>
15 <body class="REFENTRY">
16 <div class="NAVHEADER">
17 <table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
18 <tr>
19 <th colspan="5" align="center" valign="bottom">PostgreSQL Tcl Interface Documentation</th>
20 </tr>
21 <tr>
22 <td width="10%" align="left" valign="top"><a href="pgtcl-pgconndefaults.html" accesskey="P">Prev</a></td>
23 <td width="10%" align="left" valign="top"><a href="pgtcl-pgconndefaults.html">Fast Backward</a></td>
24 <td width="60%" align="center" valign="bottom"></td>
25 <td width="10%" align="right" valign="top"><a href="pgtcl-pgexecprepared.html">Fast Forward</a></td>
26 <td width="10%" align="right" valign="top"><a href="pgtcl-pgexecprepared.html" accesskey="N">Next</a></td>
27 </tr>
28 </table>
29 <hr align="left" width="100%"></div>
30 <h1><a name="PGTCL-PGEXEC" id="PGTCL-PGEXEC"></a>pg_exec</h1>
31 <div class="REFNAMEDIV"><a name="AEN787" id="AEN787"></a>
32 <h2>Name</h2>
33 pg_exec&nbsp;--&nbsp;send a command to the server<a name="IX-PGTCL-PGEXEC-2" id="IX-PGTCL-PGEXEC-2"></a></div>
34 <div class="REFSYNOPSISDIV"><a name="AEN792" id="AEN792"></a>
35 <h2>Synopsis</h2>
36 <pre class="SYNOPSIS">pg_exec [<span class="OPTIONAL"><code class="PARAMETER">-paramarray</code> arrayVar</span>] [<span class="OPTIONAL"><code class="PARAMETER">-variables</code></span>] <code class="PARAMETER">conn</code> <code class="PARAMETER">commandString</code> ?<span class="OPTIONAL"><code class="PARAMETER">args</code></span>?</pre></div>
37 <div class="REFSECT1"><a name="AEN802" id="AEN802"></a>
38 <h2>Description</h2>
39 <p><code class="FUNCTION">pg_exec</code> submits a command to the <span class="PRODUCTNAME">PostgreSQL</span> server and returns a result. Command result handles start with the connection handle and add a period and a result number.</p>
40 <p>Note that lack of a Tcl error is not proof that the command succeeded! An error message returned by the server will be processed as a command result with failure status, not by generating a Tcl error in <code class="FUNCTION">pg_exec</code>. Check for {[pg_result $result -status] == PGRES_COMMAND_OK}.</p>
41 <p>If the [<span class="OPTIONAL">-paramarray</span>] flag is provided, then a substitution is performed on the query, securely replacing each back-quote delimited name with the corresponding entry from the named array. If the array does not contain the named element, then NULL is substituted (similarly to the way an array created by -withoutnulls is generated). Each such name must occur in a location where a value or field name could appear. See pg_select for more info.</p>
42 <p>If the [<span class="OPTIONAL">-variables</span>] flag is provided, then embedded Tcl variables are passed as parameters. Variables can be flagged with ':' and array references and namespaces are supported. Complex variable names can usually be embedded with :{nasty-name-here} though no attempt at duplicating Tcl brace-escaping is made. If the variable does not exist, then NULL is substituted.</p>
43 </div>
44 <div class="REFSECT1"><a name="AEN813" id="AEN813"></a>
45 <h2>Arguments</h2>
46 <div class="VARIABLELIST">
47 <dl>
48 <dt>[<span class="OPTIONAL">-paramarray arrayname</span>]</dt>
49 <dd>
50 <p>Perform parameter substitution via `quoted` elements of the array using PQexecParams or PQSendQueryParams.</p>
51 </dd>
52 <dt>[<span class="OPTIONAL">-variables</span>]</dt>
53 <dd>
54 <p>Substitute Tcl variables found in the SQL string using PQexecParams or PQSendQueryParams.</p>
55 </dd>
56 <dt><code class="PARAMETER">conn</code></dt>
57 <dd>
58 <p>The handle of the connection on which to execute the command.</p>
59 </dd>
60 <dt><code class="PARAMETER">commandString</code></dt>
61 <dd>
62 <p>The SQL command to execute.</p>
63 </dd>
64 <dt><code class="PARAMETER">args</code></dt>
65 <dd>
66 <p>For <span class="PRODUCTNAME">PostgreSQL</span> versions greater than 7.4, <code class="PARAMETER">args</code> consists of zero or more optional values that can be inserted, unquoted, into the SQL statement using $-style substitution. Nulls are represented by the string "NULL".</p>
67 </dd>
68 </dl>
69 </div>
70 </div>
71 <div class="REFSECT1"><a name="AEN843" id="AEN843"></a>
72 <h2>Return Value</h2>
73 <p>A result handle. A Tcl error will be returned if <span class="APPLICATION">pgtcl</span> was unable to obtain a server response. Otherwise, a command result object is created and a handle for it is returned. This handle can be passed to <code class="FUNCTION">pg_result</code> to obtain the results of the command.</p>
74 </div>
75 <div class="REFSECT1"><a name="AEN848" id="AEN848"></a>
76 <h2>Example</h2>
77 <pre class="PROGRAMLISTING">pg_exec $conn {select * from table1 where id = $1 and user = $2} $id $user</pre></div>
78 <div class="NAVFOOTER">
79 <hr align="left" width="100%">
80 <table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
81 <tr>
82 <td width="33%" align="left" valign="top"><a href="pgtcl-pgconndefaults.html" accesskey="P">Prev</a></td>
83 <td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">Home</a></td>
84 <td width="33%" align="right" valign="top"><a href="pgtcl-pgexecprepared.html" accesskey="N">Next</a></td>
85 </tr>
86 <tr>
87 <td width="33%" align="left" valign="top">pg_conndefaults</td>
88 <td width="34%" align="center" valign="top"><a href="libpgtcl-ref.html" accesskey="U">Up</a></td>
89 <td width="33%" align="right" valign="top">pg_exec_prepared</td>
90 </tr>
91 </table>
92 </div>
93 </body>
94 </html>