| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 transitional//EN"> | |
| <html> | |
| <head> | |
| <title>BIRT Tutorial</title> | |
| <link rel="stylesheet" href="../style/compose.css" type="text/css"> | |
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | |
| </head> | |
| <body> | |
| <p class="head">BIRT Tutorial</p> | |
| <p class="subhead">Building a Data Set</p> | |
| <h1>Build a Data Set</h1> | |
| <p> | |
| Now we're ready to build and test our data set. | |
| <ul> | |
| <li>Find or open the Data Explorer view. | |
| <li>Select the Data Sets node in the tree view. | |
| <li>Right-click to open the context menu. (We'll just say "open the context menu" | |
| or "choose x from the context menu" from now on.) | |
| <li>Select New Data Set. The New Data Set dialog will appear. | |
| <li>Enter "Customers" for the Data Set Name field. | |
| <li>Ensure that the Data Source field shows the Sample data source created above. | |
| <li>Ensure that the Data Set Type field shows "SQL Select Query". | |
| <li>Click Finish. | |
| </ul> | |
| <h1>Data Set Editor Pages</h1> | |
| <p> | |
| The data set editor now opens. We'll use this to enter our query. Before we do, | |
| let's take a look at the pages within this editor. The data set editor provides | |
| the following pages: | |
| <dl class="arrow-list"> | |
| <dt>Query | |
| <dd>Displays your SQL SELECT statement. This is where you create and change your | |
| SQL query. Once you have the basic query, you can add a WHERE clause, adjust the set of selected columns, and | |
| more. Use the SQL editor to add computed columns that are to be calculated by | |
| the database engine. Give such columns a name using the SQL ALIAS clause.<dt>Computed Columns | |
| <dd>Computed columns are calculated by BIRT and appear | |
| to the rest of the report just like any other column. You can use JavaScript | |
| expressions, and even call into Java for advanced business logic.<dt>Parameters | |
| <dd>SQL SELECT statements can include input | |
| parameters that pass data into the query. They are marked using the SQL "?" | |
| symbol in the query. This page lets you give the parameters a name, a default | |
| value, and so on. There must be a one-to-one correspondence between entries | |
| on this page and the "?" symbols in your query. | |
| <dt>Filters | |
| <dd>Additional filters that BIRT applies to your data. Filters restrict | |
| the data passed to the report. The WHERE clause | |
| is also a filter: one executed by the database. This tab lets you define additional | |
| filters using BIRT (JavaScript) scripting. | |
| <dt>Output Columns | |
| <dd>Shows the columns within the query, and lets you define | |
| a column alias for use in the report. Note that this view shows the columns | |
| as the report will see them. The Query page shows the columns as selected from | |
| the database. | |
| <dt>Preview Results | |
| <dd>Lets you test your query and see the output. Very handy | |
| to make sure that the data is right before you proceed with report design.<dt> | |
| Data Source</dt> | |
| <dd>Displays the name of the data source for this data set so you can view or | |
| change it.</dd> | |
| </dl> | |
| <h1>Database Browser</h1> | |
| <p>Switch to the Query page if you're not already there. This page provides a | |
| simple database browser.</p> | |
| <ul> | |
| <li>Expand the Sample data source to see the schemas within this database. | |
| There is only one: "APP".</li> | |
| <li>Expand "APP" to see the list of tables in the database.</li> | |
| <li>Expand a table to see its columns.</li> | |
| <li>Drag and drop a table or column to add its name to the SQL editor.</li> | |
| </ul> | |
| <h1>Create the Query</h1> | |
| <p>Our query is very simple, so we'll just type it in:</p> | |
| <pre class="code-block">SELECT * | |
| FROM CUSTOMERS | |
| WHERE COUNTRY = 'USA'</pre> | |
| <h1>Test the Query</h1> | |
| <p> | |
| With the data set editor open, do the following: | |
| <ul> | |
| <li>Click on the Preview Results item. | |
| </li> | |
| </ul> | |
| <p> | |
| The preview page appears. This page | |
| shows the columns selected in your query listed across the top. | |
| The actual rows in your query appear down the page. | |
| <ul> | |
| <li>Verify that the list of customers appears. | |
| <li>Click OK to close the data set editor.</ul> | |
| <p>If an error dialog appears, check the following:</p> | |
| <ul> | |
| <li>Your Eclipse is installed in a directory without spaces.</li> | |
| <li>You have typed the SQL statement as shown above.</li> | |
| <li>You have not put a semi-colon at the end of your statement.</li> | |
| </ul> | |
| <h1>Edit a Data Set</h1> | |
| <p> | |
| Your new data set appears in the Data Explorer along with your data source. We can use the | |
| data set editor to change the data set, and to test it to make sure it returns | |
| the correct data. | |
| <ul> | |
| <li>Find or open the Data Explorer. | |
| <li>Open the Data Sets node. | |
| <li>Double-click the Customers data set. The Data Set editor opens. | |
| </ul> | |
| </body> | |
| </html> |