The INSERT INTO statement populates a local cube with dimension members. If the local cube is in MOLAP storage mode, the INSERT INTO statement also populates the local cube with data. The INSERT INTO statement is used after a CREATE CUBE statement to create a local cube.
<insert-into-statement> ::= INSERT INTO <target-clause>
[<options-clause>] [<bind-clause>] <source-clause>
<target-clause> ::= <cube-name> <open-paren> <target-element-list>
<close-paren>
<target-element-list> ::= <target-element>[, <target-element-list>]
<target-element> ::= [<dim-name>.[<hierarchy-name>.]]<level-name>
| <time-dim-name>
| [Measures.]<measure-name>
| SKIPONECOLUMN
<level-name> ::= <simple-level-name> | <simple-level-time>.NAME | <simple-level-time>.KEY
<time-dim-name> ::= <dim-name-type-time> | <dim-name-type-time>.NAME | <dim-name-type-time>.KEY
<options-clause> ::= OPTIONS <options-list>
<options-list> ::= <option>[, <options-list>]
<option> ::= <defer-options> | < analysis-options>
<defer-options> ::= DEFER_DATA | ATTEMPT_DEFER
<analysis-options> ::= PASSTHROUGH | ATTEMPT_ANALYSIS
<bind-clause> ::= BIND (<bind-list>)
<bind-list> ::= <simple-column-name>[,<simple-column-name>]
<simple-column-name> ::= <identifier>
<source-clause> ::= SELECT <columns-list>
FROM <tables-list>
[ WHERE <where-clause> ]
| DIRECTLYFROMCACHEDROWSET <hex-number>
<columns-list> ::= <column-expression> [, < columns-list> ]
<column-expression> ::= <column-expression-name>
<column-expression-name> ::= <column-name> [AS <alias-name>]
| <alias name> <column-name>
<column-name> ::= <table-name>.<column-name>
| <column-function> | <ODBC scalar function> | <braced-expression>
<column function> ::= <identifier>(. . .)
<ODBC scalar function> ::= {FN<column-function>}
<braced-expression> ::= (. . .)
<tables list> ::= <table-expression> [, <table-list>]
<table-expression> ::= <table-name> [ [AS] <table-alias>]
<table-alias> ::= <identifier>
<table-name> ::= <identifier>
<where clause> ::= <where-condition> [AND <where-clause>]
<where condition> ::= <join-constraint> | <application constraint>
<join-constraint> ::= <column-name> = <column-name>
| <open-paren><column-name> = <column-name><close-paren>
<application-constraint> ::= (. . .)
| NOT (. . .)
| (. . .) OR (. . .)
<identifier> ::= <letter>{<letter>|<digit>|<underline>|<dollar>|<sharp>}. . .
INSERT INTO MyCube (Year, Month.Name, Month.Key, [Product Group], [Product Name], Country, Sales, Cost)
OPTIONS DEFER_DATA
SELECT MyTable.Year, MyTable.Month, MONTH(MyTable.Month), MyTable.ProdGroup, MyTable.ProdName, MyTable.Country, MyTable.Sales, MyTable.Cost
FROM MyTable
WHERE MyTable.SalesRep = "Amir" and MyTable.CustomerGroup = "Industry"
INSERT INTO MyCube (Year, Month, [Product Group], [Product Name], Country, Sales, Cost)
OPTIONS PASSTHROUGH SELECT MyTable.Year, MyTable.Month, MyTable.ProdGroup, MyTable.ProdName, MyTable.Country, MyTable.Sales, MyTable.Cost
FROM MyTable
WHERE MyTable.SalesRep = "Amir" and MyTable.CustomerGroup = "Industry"
Note The PASSTHROUGH option specifies that the SELECT clause that follows it is to be passed directly to the database engine with no parsing by PivotTable® Service.
INSERT INTO MyCube (Year, Month, [Product Group], [Product Name], Country, Sales, Cost)
DIRECTLYFROMCACHEDROWSET 0x00001284
Note The DIRECTLYFROMCACHEDROWSET keyword directs data to be read from the address in memory identified immediately after the keyword. It is the responsibility of the client application to specify the correct address in memory. At run time, the number is assumed to be the in-process address of an IUnknown pointer to an OLE DB rowset.
CREATE CUBE MyCube (
DIMENSION TimeDim TYPE TIME,
LEVEL MyYear TYPE YEAR,
LEVEL MyQtr TYPE QUARTER,
LEVEL MyMonth TYPE MONTH,
DIMENSION Products,
LEVEL [Product Group],
LEVEL [Product Name],
DIMENSION Geography,
LEVEL State,
LEVEL City,
MEASURE [Sales]
FUNCTION SUM
FORMAT ‘Currency’,
MEASURE [Units Sold]
FUNCTION SUM
)
INSERT INTO MyCube (TimeDim, [Product Group], [Product Name], State, City, Sales, [Units Sold])
OPTIONS DEFER_DATA
SELECT MyTable.TransDate, MyTable.ProdGroup, MyTable.ProdName, MyTable.State, MyTable.City, MyTable.Sales, MyTable.UnitsSold
FROM MyTable
WHERE MyTable.SalesRep = "Jacobsen" and MyTable.CustomerGroup = "Industry"
The PASSTHROUGH option causes the SELECT clause to be passed directly to the source database without modification by PivotTable Service. If PASSTHROUGH is not specified, PivotTable Service parses the query and formulates a set of queries equivalent to the original that is optimized for the source database and index structures. This set of queries is often more efficient than the specified query.
The DEFER_DATA option causes the query to be parsed locally and executed only when necessary to retrieve data to satisfy a user request. DEFER_DATA is used to specify that a local cube is defined in the ROLAP storage mode.
The ATTEMPT_DEFER option causes PivotTable Service to attempt to parse the query and defer data loading if successful, or, if the query cannot be parsed, to process the specified query immediately as if the PASSTHROUGH had been specified.
The ATTEMPT_ANALYSIS option causes PivotTable Service to attempt to parse the query and formulate an optimized set of queries (process in the MOLAP mode), or, if the query can’t be parsed, to process the specified query immediately as if the PASSTHROUGH had been specified.
In the following matrix, “PT” indicates passthrough.
Parse | Neither PassThrough Nor Attempt_Analysis | PassThrough | Attempt_Analysis | |
---|---|---|---|---|
Neither DEFER_DATA nor ATTEMPT_DEFER | Succeeded | MOLAP | MOLAP(PT) | MOLAP |
Failed | Error | n/a | MOLAP(PT) | |
DEFER_DATA | Succeeded | ROLAP | Error | ROLAP |
Failed | Error | n/a | Error | |
ATTEMPT_DEFER | Succeeded | ROLAP | MOLAP(PT) | ROLAP |
Failed | MOLAP(PT) | n/a | MOLAP(PT) |