dfs_serv.xml using
an external entity defined in the DTD section. Additional configuration
information, including an example, appears at the end of this topic.
OptionSet element,
and a name attribute of SQL:<OptionSet name="SQL"> ... </OptionSet>SQL nodes can be nested with the outer-most node, which is the script. Nested nodes correspond to SQL commands that run within the script. Additional XML elements provide execution context for the SQL nodes.
Option and OptionSet elements
are valid within an SQL node:
<Option name="SQLErrorMediationAction">Error
mediation action</Option><Option name="SQLState">SQL
state expression</Option>HY001, or as a prefix matching
any SQL state starting with a specified prefix. In addition, a leading + character
(concatenation operator) can be prepended to the mnemonic to add the
SQL state to the current set of constraining SQL states. Without the
leading concatenation operator, the specified SQL states replaces
any SQL states that were previously specified.
<Option name="Command">SQL
command</Option>@n syntax
where n is a single parameter number corresponding
to the n'th column of the outer command's result set. Note
that commands can be nested only once. Here is an example of the nested
command:<OptionSet name="SQL"> ... <Option name="Command">outer query command</OptionSet> <OptionSet name="SQL"> ... <Option name="Command">parameterized inner command 1</Option> </OptionSet> ... <OptionSet name="SQL"> ... <Option name="Command">parameterized inner command n</Option> </OptionSet> </OptionSet>
<Option name="Condition">SQL
Boolean scalar result query</Option>1,
all sibling SQL nodes are executed. Otherwise, they are skipped. Only
the first condition is processed within an SQL node parent.
1 when table T has
at least one row matching the WHERE clause,
which is not shown. If the query returns 1,
sibling SQL nodes contained in the parent SQL node are executed:<Option name="Condition"> select cast(case when count(*) > 0 then 1 else 0 end as integer) from T where ...</Option>
Startup.Epilog phase.
Error mediation prevents CREATE TABLE commands
from stopping script execution when the table already exists in the
data store. Errors with SQL states beginning with 42S are
excluded from the stop action. Also, if the C_STORE_MDS catalog requires
credentials to connect, you can supply those in the connection string.
<?xml version="1.0" encoding="utf-8" ?>
<OptionSet name="SQL">
<!--
Default phase, SQL error mediation control
-->
<Option name="name">MDS to STORE_MDS store</Option>
<Option name="SQLErrorMediationAction">STOP</Option>
<Option name="SQLErrorMediationSSMatchMode">EXCLUDE</Option>
<!--
MDS Store script
-->
<OptionSet name="SQL">
<Option name="Phase">Stop.Prolog</Option>
<Option name="SQLState">42S</Option>
<Option name="ConnectionString">
driver=FEDSQL;conopts=((security=NO;catalog=C_STORE_MDS);
(security=NO;catalog=C_MDS))
</Option>
<!--
Result set generator command: Enumerate all MDS tables...
-->
<Option name="Command">
select TABLE_SCHEM,
TABLE_NAME
from DICTIONARY.TABLES
where TABLE_CAT='C_MDS' and
TABLE_TYPE='TABLE'
</Option>
<!--
Result set iterator command:
Store MDS catalog tables in C_STORE_MDS "mirror" catalog
-->
<OptionSet name="SQL">
<Option name="Command">
create table C_STORE_MDS.S."@2" as
select * from C_MDS."@1"."@2" where 1=0
</Option>
</OptionSet>
<OptionSet name="SQL">
<Option name="Command">
delete from C_STORE_MDS.S."@2"
</Option>
</OptionSet>
<OptionSet name="SQL">
<Option name="Command">
insert into C_STORE_MDS.S."@2"
select * from C_MDS."@1"."@2"
</Option>
</OptionSet>
</OptionSet>
</OptionSet>store_mds.xml. After saving
the script, edit the dfs_serv.xml configuration
file as highlighted in the following example: <?xml version="1.0" encoding="UTF-8"?> <DOCTYPE Config [ <ENTITY % entities SYSTEM "dfs_entities.dtd"> %entities; <ENTITY MDS_SCRIPT SYSTEM "store_mds.xml"> ]> <Config name="TSConfig"> <!-- Common server options --> &SERVER_COMMON; <!-- Run the MDS script --> &MDS_SCRIPT; </Config>
dfs_serv.xml configuration file,
see SAS Federation Server Configuration Reference.