Menu

workflow

Katherine E. Lightsey


Workflow


chain_of_command_pattern

    declare @command_stack [xml] = 
    N'<object_stack stack_type="command" name="<command_name>">
        <object_signature />
        <object object_type="receiver" >
            <executable>
                <parameters>@output [xml] output</parameters>
                <sql>select @output = (<select statement> 
                    for xml path(output'), root(N'output_tree'));</sql>
            </executable>
            <next>
                <object_stack stack_type="command" name="<command_name_1>" />
                ...
                <object_stack stack_type="command" name="<command_name_n>" />
            </next>
        </object >
        <object object_type="result" />
    </object_stack >';

Setter / Run
- invoker object

    declare procedure [workflow].[run] @workflow [xml]
    as
        declare @output [xml], @next [xml];

        execute sp_execute
        @sql=@workflow.value(N'(/command/receiver/sql/text())[1]', N'[nvarchar](max)'),
        @parameters=@workflow.value(
            N'(/command/receiver/parameters/text())[1]', N'[nvarchar](max)'),
        @output=@output output;

        execute [logging].[set_entry] @typed_entry=@output;

        set @next = @output.query(N'(/command/next)[1]');
        if (@next is not null)
                execute procedure [workflow].[get] @workflow=@next;
    go

Related

Wiki: chain_of_command_pattern
Wiki: chamomile

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.