Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Scenario

Div
classtime

Image Removed Estimated Time: 10 min

In this scenario, we will insert the SQL-file Macro on a Confluence page by inserting Markup from the menu. Our SQL-file Macro will reference a file containing SQL located within the /script (default) directory of your Confluence server.

Background

Our scenario will use a Data Source Profile called "BookWarehouse" to query a database table called "BOOKS". The table contains the following columns and rows:

Code Block
languagesql
SQL > select * from books;
+----+----------------------------+---------------------+-------+
| id | title                      | author              | price |
+----+----------------------------+---------------------+-------+
|  1 | The Grapes of Wrath        | John Steinbeck      | 12.99 |
|  2 | Nineteen Eighty-Four       | George Orwell       |  8.99 |
|  3 | The Wind-Up Bird Chronicle | Haruki Murakami     |  7.99 |
|  4 | Don Quixote                | Miguel De Cervantes | 29.99 |
|  5 | Pilgrims Progress          | John Bunyan         | 17.99 |
|  6 | Robinson Crusoe            | Daniel Defoe        | 29.05 |
|  7 | Gullivers Travels          | Jonathan Swift      | 15.98 |
|  8 | Tom Jones                  | Henry Fielding      | 13.59 |
|  9 | Clarissa                   | Samuel Richardson   | 13.59 |
| 10 | Tristram Shandy            | Laurence Sterne     |  7.59 |
+----+----------------------------+---------------------+-------+

Our query will be stored within a file called "books.sql" and we will work with our Confluence administrator to place it within the /script (default) directory on our Confluence server. Our query looks like:

Code Block
languagesql
SELECT title as "Title", author as "Author", price as "Retail Price" FROM books WHERE price < 30 ORDER BY title;

Steps

The following steps will demonstrate how to use Markup to insert the SQL-file Macro on a Confluence page.

...

border0
heading0
multiplefalse
enableHeadingAttributesfalse
columnAttributesstyle="border:0;width=5%;",style="border:0;width=65%;",style="border:0;width=30%;max-width=30% !important;"
idsteps_table
enableSortingfalse
enableHighlightingfalse

...

Include Page
SUPPORT:Using SQL File with Markup - 9.x

...

Create Confluence page

Create a Confluence page that will eventually contain the SQL-file Macro needed to list out your books.

  1. Create a page named Classic Books in a space accessible to the desired audience.
  2. Click Save to save the new page.

...

and earlier
SUPPORT:Using SQL File with Markup - 9.x

...

Insert the SQL-file Macro using the Insert Markup Menu

Edit the Classic Books page and:

...

Type the follwing into the editor window. Note the dataSource name and file name referenced. 

Code Block
 {sql-file:dataSource=BookWarehouse|file=books.sql}

...

Alternative:

...

Insert the SQL-file Macro using Markup on page

Edit the Classic Books page and:

  1. On the page, begin typing "{" (open parenthesis) and then type "sql-"
  2. Select "sql-file" from the available list of Macros.
  3. The Macro editor dialog will appear.
  4. Type "books.sql" into the required "File" field.
  5. Select "BookWarehouse" as the Data source name
  6. Click Insert to insert your Markup within the page.

  7. Click Save to save your page and view your results.

How to insert Markup from the menu

Image Removed

Image Removed

Explore Tutorials

We've prepared a number of tutorials which demonstrate how to use our SQL Macros with the native Chart Macro.

Image Removed

and earlier