Example Wizard code

This example illustrates code generated by the Report Data Wizard.

This is the code that was generated by the example covered in Using the Report Data Wizard

 SCHEMA officestore 

 TYPE officestore_data RECORD
    account RECORD
        userid LIKE account.userid,
        email LIKE account.email 
    END RECORD,
    orders RECORD
        orderid LIKE orders.orderid,
        orderdate LIKE orders.orderdate,
        shipaddr1 LIKE orders.shipaddr1,
        shipaddr2 LIKE orders.shipaddr2,
        shipcity LIKE orders.shipcity,
        shipstate LIKE orders.shipstate,
        shipzip LIKE orders.shipzip 
    END RECORD
 END RECORD

 FUNCTION run_officestore_to_handler(handler)
    DEFINE
        data officestore_data,
        handler om.SaxDocumentHandler 
    DECLARE cur CURSOR FOR
        SELECT 
            account.userid,
            account.email,
            orders.orderid,
            orders.orderdate,
            orders.shipaddr1,
            orders.shipaddr2,
            orders.shipcity,
            orders.shipstate,
            orders.shipzip 
        FROM 
            account,
            orders 
        WHERE 
            orders.userid = account.userid 
        ORDER BY
            account.userid 

    START REPORT officestore_report TO XML HANDLER handler 
    FOREACH cur INTO data.*
       OUTPUT TO REPORT officestore_report(data.*)
    END FOREACH
    FINISH REPORT officestore_report 
    CLOSE cur 
 END FUNCTION

 REPORT officestore_report(data)
    DEFINE
        data officestore_data 
    ORDER EXTERNAL BY 
        data.account.userid 

    FORMAT
        ON EVERY ROW
            PRINT data.*
 END REPORT
Note:
  • Lines 3-17 define a user-type named office_data, which is a RECORD consisting of sub-records for the fields that were selected in the Result Set page from the tables selected in the Table Selection page.
  • Lines 19-48 define the run_officestore_to handler function.
    • Lines 23-40 declare a cursor for the SQL SELECT statement to retrieve the data. The table join and the sort order were specified in the Define Joins and Order By pages.
    • Lines 42-46 fetch the report data and send it to the REPORT function.
  • Lines 50-59 define the REPORT function, which outputs the data to the Genero Report Engine.

See The BDL File for additional information about the BDL functions and statements used in conjunction with reports.