Release 10.1A: OpenEdge Development:
Progress Dynamics Basic Development

> ## Defining an SDO with a temp-table like a database table

> Temp-table SDOs are an important technique.

> | To define a temp-table that is identical to an actual database table:

> 1. From the SDO wizard, choose Define Temp-tables.

> 2. In the Temp-Table Maintenance dialog box, choose the database table instead of a table from the temp-db database, as shown:

> 3. In the Query Builder, select the temp-table version of your table from the temp-tables pseudo-database rather than the database table itself, as shown:

> Progress can properly distinguish between a temp-table and a database table of the same name, as in the example `Department` `Temp-Table` SDO. References to the unqualified table name should be taken to mean the temp-table. You can specify the database table using the database name qualifier. So, in the Department SDO, you have an initialization block of code in the procedure’s main block similar to the one for the first `TTMyTable` example.

> In the following code, you define some place-holder records of your own, and then copy the actual department names and codes from the database table into the temp-table:

>     /* *********************** Main Block *********************** */
>      &IF DEFINED(UIB_IS_RUNNING) <> 0 &THEN
>       RUN initializeObject.
>      &ENDIF
>     DEFINE VARIABLE cMessage AS CHAR  NO-UNDO.
>     DEFINE VARIABLE iRec AS INT  NO-UNDO.
>     DO iRec = 1 TO 9:
>       CREATE department.
>       ASSIGN department.DeptCode = '10'  + STRING(iRec)
>           department.DeptName = 'Dept ' + STRING(iRec).
>     END.
>     FOR EACH sports2000.Department:
>       CREATE department.
>       ASSIGN department.DeptCode = sports2000.department.DeptCode
>           department.DeptName = sports2000.department.DeptName.
>     END.
>     FOR EACH department:
>       cMessage = cMessage + department.deptcode
>         + " " + department.deptname + CHR(10).
>     END.
>     MESSAGE cMessage VIEW-AS ALERT-BOX.

> Displaying all of those values when the SDO starts up confirms that Progress has correctly interpreted your references to the sports2000.`Department` database table and the `Department` temp-table, as shown in Figure 11–3.

> Figure 11–3: All values confirmation message box

> Although you must define each viewer or browser you build using a particular SDO, you can connect these visual objects at run time to any SDO that supplies the right fields for them. In the case of the viewer, this means that the field names the viewer asks for must be in the SDO that is its `Data-Source`. They do not have to be in the same order, and they do not have to be all the fields defined in the SDO. It does not matter whether the SDO uses a temp-table or an actual database table as its data source. So, a viewer built against a database table (meaning that a SmartDataObject defined against a database table was named in the viewer’s wizard) can be linked to an SDO built against a similar temp-table and used with it in an application. Because it is simply asking for field values, it will not know the difference.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095