Tables Tutorial

 

Introduction. 1

Instructions 1

 

See also:         

Working with Tables

Table Concepts

Building your First Form

 

 

Introduction

 

In this exercise we will create a form containing a table. We assume that you have some familiarity with using the Ebase Designer. If not, you are recommended to start with the tutorial Building your First Form.

 

We will build a small application for maintaining a CD collection. It will support the following functions:

 

 

This application will make use of the following database tables which are included in the Ebase Samples Database:

 

  • mycds

this is the main CDs table

  • cd_classifications

main classifications e.g. Popular, Classical, Jazz etc

  • cd_sub_classifications

sub classifications within the main classification

 

Note: If you need to build these tables, please see script tables_exercise_schema.sql in the root ufs directory. This schema is for the MySQL database but can easily be adjusted for other DBMS's.

 

These instructions contain a lot of detail so you may find it easier to print this document.

 

Instructions

 

Import the database tables

 

 

Build the classification dynamic list

 

This will be used to classify a CD.

 

 

Build the sub-classification dynamic list

 

This will be used to further classify a CD.

 

 

Create a business view

 

 

Create the USER project

 

 

Create the form and set up table display

 

 

You should now see a display like this:

 

 

 

 

 

 

 

The table should now look like this:

 

 

 

Add database integration

 

Add an FPL script to load the table from database:

 

 

Add an update table button and an FPL script to perform the updates:

 

 

Add a sequence to number the CDs as we enter them:

 

 

Add a script to use the sequence

 

sequence CDS;

set CDS-CD_ID = $NEXT_SEQUENCE_ID;

 

Now test the form for the first time by clicking on the Run icon  in the form toolbar.

 

Initially the table is empty, so click the Add Row button, and a row appears with CD_ID 1. However, the table is much too wide because the field lengths for the individual columns are too large and exceed the percentage width specifications we have assigned.

 

To correct this, return to the Ebase Designer, right-click on the column header texts, select Edit column properties, select the Presentation tab and click on use value under Display Length and change the display length value to:

 

Column

Display length

ARTIST

25

TITLE

40

COMPOSER

15

CLASSIFICATION

10

SUB_CLASSIFICATION

10

RATING

1

 

Also, set the CD_ID column read only by right-clicking the CD_ID column header text and clicking Display Only.

 

Now try running the form again. You may need to further adjust these lengths depending on the width of your screen.

 

You will notice that CD ID 2 is assigned. Don't worry about this as we can reset the sequences once we have the form working.

 

Set up the classification lists

 

 

Run the form again

 

 

Final touches

 

 

Optional Further Enhancements

 

Adding a reviews button column

 

We'd like to be able to add a button on each row which, when clicked, takes us to another page which allows the user to enter a review of the CD. This could be done as follows:

 

goto page REVIEW_PAGE;

·         Right-click the column header for the Review button, select Edit Actions, select the On Click tab if not already selected then click the Add Scripts button and add the GOTO_REVIEW_PAGE script. Click OK twice. 

 

Making the table searchable

 

if [ SEARCH_FIELD_INPUT != '' ]

  set SEARCH_FIELD_FOR_DB = '%'+SEARCH_FIELD_INPUT+'%';

else

  set SEARCH_FIELD_FOR_DB = '%';

endif

fetchtable CDS;

o        Right-click the Go button and select Edit Actions, select the On Click tab if not already selected, then click the Add Scripts button and add the APPLY_SEARCH_CRITERIA script. Click OK twice.