Startup.Epilog and Stop.Prolog.
To run a script, add the name of the script to the server’s
configuration file, dfs_serv.xml.
OptionSet element
that includes a name attribute of SQL:<OptionSet name="SQL"> ... </OptionSet>
<OptionSet name="SQL">
...
<Option name="Command">command 1</Option>
<Option name="Command">command 2</Option>
...
</OptionSet>
<OptionSet name="SQL">
<Option name="Condition">SQL Boolean scalar result query</Option>
<OptionSet name="SQL">
<Option name="Command">command 1</Option>
<Option name="Command">command 2</Option>
...
</OptionSet>
...
<OptionSet name="SQL">
...
<Option name="Command">command 1</Option>
<Option name="Command">command 2</Option>
...
</OptionSet>
</OptionSet>
<OptionSet name="SQL">...</OptionSet>OptionName.
<Option name=”name”>SQL
node name or description</Option><Option name="SQLErrorMediationAction">Error
mediation action</Option>STOPSTOP is
the default mediation action.
CONTINUE<Option name="SQLErrorMediationSSMatchMode">SS
match mode</Option>EXCLUDEINCLUDEIGNORE<Option name="Phase">Server
phase</Option>Startup.Epilog and Stop.Prolog.
Startup.EpilogStartup.Epilog is executed on start-up of SAS Federation Server before listening for connections
and after administration DDL can be executed. These scripts can connect to any configured
data service and execute SQL that is run as the process user.
Stop.PrologStop.Prolog is executed on SAS Federation Server shutdown after quiescing or dropping client
connections. These scripts can connect to any configured data service and execute
SQL that is run as the process user.
<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="ConnectionString">connection-string</Option><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>
<Option name="AutoCommit">value</Option>true (default) and false.
TRUEFALSEStartup.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.