7 | | This is a macro that enables you to place tables resulting from SQL queries into a Trac wiki page. For usage examples, see below. |
| 7 | This is a macro that enables you to place tables resulting from SQL queries into a Trac wiki page. |
| 8 | |
| 9 | Use the '''SQLTable''' macro as follows: |
| 10 | |
| 11 | {{{ |
| 12 | {{{#!SQLTable |
| 13 | SELECT COUNT(id) AS "Number of Tickets" |
| 14 | FROM ticket |
| 15 | }}} |
| 16 | }}} |
| 17 | |
| 18 | The result will be a table displayed in a html page. |
| 19 | |
| 20 | You can also use wiki markup in the table: |
| 21 | |
| 22 | {{{ |
| 23 | {{{#!SQLTable |
| 24 | SELECT '[milestone:' || name || ' ' || name || ']' AS name, due, completed, description |
| 25 | FROM milestone |
| 26 | }}} |
| 27 | }}} |
| 28 | |
| 29 | Use the '''SQLScalar''' macro: |
| 30 | |
| 31 | {{{ |
| 32 | {{{#!SQLScalar |
| 33 | SELECT COUNT(id) AS "Number of Tickets" |
| 34 | FROM ticket |
| 35 | }}} |
| 36 | }}} |
| 37 | |
| 38 | The result will be a single number. |
43 | | == Usage |
44 | | |
45 | | Use the SQLTable macro as follows: |
46 | | |
47 | | {{{ |
48 | | {{{#!SQLTable |
49 | | SELECT count(id) as "Number of Tickets" |
50 | | FROM ticket |
51 | | }}} |
52 | | }}} |
53 | | |
54 | | The result will be a table displayed in a html page. |
55 | | |
56 | | You can also use wiki markup in the table: |
57 | | |
58 | | {{{ |
59 | | {{{#!SQLTable |
60 | | SELECT '[milestone:' || name || ' ' || name || ']' as name, due, completed, description |
61 | | FROM milestone |
62 | | }}} |
63 | | }}} |
64 | | |
65 | | Use the SQLScalar macro: |
66 | | |
67 | | {{{ |
68 | | {{{#!SQLScalar |
69 | | SELECT count(id) as "Number of Tickets" |
70 | | FROM ticket |
71 | | }}} |
72 | | }}} |
73 | | |
74 | | The result will be a single number. |
75 | | |