Previous Topic Next topic Print topic


DECLARE DATASET

Defines a typed or an untyped DataSet.

Syntax:

DECLARE <typed> DATASET
>>--EXEC ADO---DECLARE dataset_name DATASET----------------------->

 >--+-FROM dataset_xml_file_spec---------------------------------+
    +-LIKE src_dataset_name--------------------------------------+
    |                                                            |
    |       +---- , -----+                                       |
    |       V            |                                       |
    +-FOR---datatable_name---.--------------.----.-------------.-+ 
                             +-optrelations-+    +optschemasave+

 >--END-EXEC----><

where

optrelations:
 >-.------------------------------------------------------------------------.--><
   |                                                                        |
   | + ----------------- , ---------------------------------------------+   |  
   | V                                                                  |   |
   +---.--------.-RELATION rel_name child_tbl (column_list)REFERENCES-> |   |
       +-NESTED-+                                                       |   |
              >--parent_tbl (column_list)-.------------------.----------+---+                                                     
                                          +optwithconstraints+

optschemasave:
 >----.--------------------------------------.--------------------><
      +-SAVE SCHEMA TO dataset_xml_file_spec-+

optwithconstraints:
>--.------------------------------------------------------------.-><
   +-WITH CONSTRAINTS-.-------------.-.----------.-.----------.-+
                      +-accrej_rule-+ +-del_rule-+ +-upd_rule-+
                         
accrej_rule:
>---ON ACCEPT OR REJECT -.-CASCADE---.----------------------------><
                         +-NO ACTION-+ 
 
del_rule:
>---ON DELETE -.-CASCADE-----.------------------------------------><
               +-NO ACTION---+
               +-SET DEFAULT-+  
               +-SET NULL----+  
                          
upd_rule:
>---ON UPDATE -.-CASCADE-----.------------------------------------><
               +-NO ACTION---+
               +-SET DEFAULT-+  
               +-SET NULL----+
DECLARE <untyped> DATASET
>>--EXEC ADO---DECLARE dataset_name UNTYPED DATASET----END-EXEC---><

Parameters:

dataset_name The DataSet to be declared.
dataset_xml_file_spec The location of the DataSet XML file that specifies the characteristics for the declared DataSet.
src_dataset_name The name of the DataSet that specifies the characteristics for the declared DataSet.
datatable_name The declared DataTable to be included in this DataSet.
rel_name The name of a relation.
child_tbl (column_list) A specification of the table and columns which define the child key (foreign).
parent_tbl (column_list) A specification of the table and columns which define the parent key.
SAVE SCHEMA TO Saves the schema of the DataSet into an XSD file.

Comments:

When you declare a schema with a DataSet (typed), it is checked at compile time and optionally stored in an XSD file. If you do not declare a schema with the DataSet (untyped), then no compile time checking is done.

A DataSet consists of DataTables and the relationships between these tables.

All DataTables specified in a DECLARE DATASET statement must have a corresponding DECLARE DATATABLE. You can optionally specify parent key and child key relationships between these tables with the RELATION clause.

If WITH CONSTRAINTS is specified, then primary key and foreign key constraints will be created (if they do not already exist) in the parent and child DataTables, respectively. You can set rules to specify the effect of changes to a parent row on related child rows if WITH CONSTRAINTS is specified.

Example:

     EXEC ADO
        DECLARE ds DATASET
        FOR Customers, Orders, "Order Details"
        RELATION custord Orders(CustomerID) REFERENCES Customers(CustomerID),
        RELATION orditems "Order Details"(OrderID) REFERENCES Orders(OrderID)
     END-EXEC

     EXEC ADO
        DECLARE ds UNTYPED DATASET
     END-EXEC
Previous Topic Next topic Print topic