~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/dynamic.rst

  • Committer: Lee Bieber
  • Date: 2010-11-14 23:15:42 UTC
  • mfrom: (1929.1.42 warning-stack-frame)
  • Revision ID: kalebral@gmail.com-20101114231542-fnnu6ydd2p17n582
Merge Monty - fix bug 672372: some functions use > 32k stack

Show diffs side-by-side

added added

removed removed

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