1 |
tony |
37 |
Script Engine Playground
|
2 |
|
|
========================
|
3 |
|
|
|
4 |
|
|
This example application illustrates use of the TIBXScript SQL script engine. It works with
|
5 |
|
|
the example employee database and comes with various test scripts to illustrate how it works.
|
6 |
|
|
These are all located in the "tests" directory.
|
7 |
|
|
|
8 |
|
|
Compile and run the application after first ensuring that the example employee database is
|
9 |
|
|
available on the local server. If it is on a remote server, then you will have to adjust
|
10 |
|
|
the IBDatabase1.DatabaseName property accordingly.
|
11 |
|
|
|
12 |
|
|
You can just type SQL queries into the left hand text box and click on "Execute" to
|
13 |
|
|
run them. The results appear in the right hand text box. Select queries are supported
|
14 |
|
|
by opening a new dynamically created window with a grid containing the query results. This
|
15 |
|
|
window is non-modal and multiple query results can be shown simultaneously. The grid
|
16 |
|
|
is a TIBDynamicGrid and clicking on the column header will resort the grid using the
|
17 |
|
|
selected column.
|
18 |
|
|
|
19 |
|
|
The test scripts are loaded in the left hand text box by clicking on the "Load Script"
|
20 |
|
|
button. The scripts are:
|
21 |
|
|
|
22 |
|
|
1. CreateCountriesTable.sql
|
23 |
|
|
|
24 |
|
|
This adds a new table "COUNTRIES" to the employee database and then populates
|
25 |
|
|
it with country data including the country name and ISO2 and 3 character shortnames.
|
26 |
|
|
|
27 |
|
|
2. CreateCountriesTablewithError.sql
|
28 |
|
|
|
29 |
|
|
This does the same as the above, except that the first insert statement contains
|
30 |
|
|
a syntax error. It may be used to experiment with the "Stop on First Error" checkbox,
|
31 |
|
|
and shows how the script engine can recover and continue from (some) syntax errors.
|
32 |
|
|
|
33 |
|
|
3. DeptListView.sql
|
34 |
|
|
|
35 |
|
|
This script adds a complex View to the database and tests the script engine in complex
|
36 |
|
|
scenarios, such as recursive queries.
|
37 |
|
|
|
38 |
|
|
4. createproc.sql
|
39 |
|
|
|
40 |
|
|
This script adds three simple stored procedures. It demonstrates the different ways
|
41 |
|
|
that procedure bodies can be declared (ISQL compatible, standard terminator and no
|
42 |
|
|
terminator). Use of comments is also demonstrated.
|
43 |
|
|
|
44 |
|
|
5. ParameterisedQueries.sql
|
45 |
|
|
|
46 |
|
|
This script demonstrates the use of IBX style query parameters for BLOB columns.
|
47 |
|
|
In this case a new column "Image" is added to the COUNTRY Table and an image in
|
48 |
|
|
png format (the flag of St George) is added to the entry for England. The value
|
49 |
|
|
of the Image column is given by a parameter ":MyImage". This is resolved by the a
|
50 |
|
|
pplication which asks for the file containing the image to be placed in the field.
|
51 |
|
|
You should locate and return the "flag_en.png" file.
|
52 |
|
|
|
53 |
|
|
Note that the interactive resolution of the parameter is an example. The parameter
|
54 |
|
|
resolution is carried out by an event handler that could, for example,
|
55 |
|
|
have looked for a file which might conventionally have been called "MyImage.bin"
|
56 |
|
|
to correspond to the query parameter.
|
57 |
|
|
|
58 |
|
|
6. Reverseall.sql
|
59 |
|
|
|
60 |
|
|
Reverses out the above.
|
61 |
|
|
|
62 |
|
|
7. SelectQuery.sql
|
63 |
|
|
|
64 |
|
|
Illustrates handling of select queries.
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
|