~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/dynamic.rst

  • Committer: devananda
  • Date: 2009-07-01 17:38:47 UTC
  • mto: (1093.1.7 captain)
  • mto: This revision was merged to the branch mainline in revision 1095.
  • Revision ID: devananda.vdv@gmail.com-20090701173847-3n3mbtessg5ff35e
refactored function/benchmark into plugin/benchmark

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Dynamic SQL
2
 
===========
3
 
 
4
 
In Drizzle you can use the EXECUTE command along with :doc:'user defined variables <variables>'
5
 
to create SQL in a dynamic manner on the server. An exmaple of this is:
6
 
 
7
 
SET @var= "SELECT 1";
8
 
EXECUTE @var;
9
 
 
10
 
You can also omit the variable and just insert the SQL directly:
11
 
 
12
 
EXECUTE "SELECT 1";
13
 
 
14
 
By adding WITH NO RETURN you can have EXECUTE then no errors will be
15
 
generated and no data will be returned by the execution of the statement.
16
 
 
17
 
If you want to launch the query in a separate session, you can do that with
18
 
the following:
19
 
EXECUTE "SELECT 1" CONCURRENT;
20
 
 
21
 
By adding "WAIT" to a CONCURRENT execute, you can have the session that
22
 
called EXECUTE wait till the child is finished before returning.
23
 
 
24
 
The query will run in a new session and will execute as the user that
25
 
launched it. It can be killed via KILL and the system limit on total number
26
 
of sessions will be enforced.