~drizzle-trunk/drizzle/development

1878.5.4 by Brian Aker
Update documentation.
1
Dynamic SQL
1900.2.4 by Stewart Smith
fix more docs warnings: underline/overline too short
2
===========
1878.5.4 by Brian Aker
Update documentation.
3
1994.4.1 by Marisa Plumb
doc modifications
4
Dynamic SQL enables you to build SQL statements dynamically at runtime. It can be generated within an application or from the system tables and then executed against the database to manipulate the data. You can create more general purpose, flexible applications by using dynamic SQL since the full text of a SQL statement may be unknown at the time of compilation.
5
6
Dynamic SQL allows you to execute DDL statements (and other SQL statements) that are not supported in purely static SQL programs.
7
1945.3.5 by Marisa Plumb
more sql doc modifications
8
In Drizzle you can use the EXECUTE command along with :doc:'user defined variables <variables>'
2165.2.5 by Andrew Hutchings
Make fixes to temporal docs
9
to create SQL in a dynamic manner on the server. An exmaple of this is:
10
11
.. code-block:: mysql
1994.4.1 by Marisa Plumb
doc modifications
12
13
	SET @var= "SELECT 1";
14
	EXECUTE @var;
15
2165.2.5 by Andrew Hutchings
Make fixes to temporal docs
16
You can also omit the variable and just insert the SQL directly:
17
18
.. code-block:: mysql
1994.4.1 by Marisa Plumb
doc modifications
19
20
	EXECUTE "SELECT 1";
21
22
By adding WITH NO RETURN you can have EXECUTE and no errors will be
1921.4.1 by Brian Aker
Adding in support for EXECUTE to have WITH NO RETURN.
23
generated and no data will be returned by the execution of the statement.
1921.4.2 by Brian Aker
Adding in concurrent execute support.
24
25
If you want to launch the query in a separate session, you can do that with
2165.2.5 by Andrew Hutchings
Make fixes to temporal docs
26
the following:
27
28
.. code-block:: mysql
1921.4.2 by Brian Aker
Adding in concurrent execute support.
29
1994.4.1 by Marisa Plumb
doc modifications
30
	EXECUTE "SELECT 1" CONCURRENT;
1958.1.1 by Brian Aker
Fix clash in parser with wait().
31
1921.4.2 by Brian Aker
Adding in concurrent execute support.
32
The query will run in a new session and will execute as the user that
33
launched it. It can be killed via KILL and the system limit on total number
34
of sessions will be enforced.
1994.5.29 by Stewart Smith
add FIXME for EXECUTE doing things inside explicit txn
35
2165.2.3 by Andrew Hutchings
Add favicon to docs
36
.. todo::
37
38
   EXECUTE executes the statements inside an explicit transaction.