AtanaSuite Connect - Tips

Expansion Snippet Example

By: | Posted on: | Category:

Here is the XML code for a sample Expansion snippet. In this example, the "sts+TAB" shortcut keys may be used to insert a SELECT TOP SQL statement into the SQL editor window prompting the user for count, table and where clause.

NOTE - This sample is also included in the example snippet.xml file that is created in the users snippets folder upon first use of snippets within AtanaSuite.

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>SELECT TOP *</Title>
            <Shortcut>sts</Shortcut> <!-- typing this shortcut followed by the Tab key will insert this snippet -->
            <Description>Selects TOP X rows from a table/view</Description>
            <Author>Atanasoft</Author>
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType><!-- Expansion inserts new text at the caret; SurroundsWith places new text before and after the selection -->
            </SnippetTypes>
        </Header>
        <Snippet>
            <Declarations>
                <Literal>
                    <ID>table</ID>
                    <Default>_table_</Default>
                    <ToolTip>The table to select from.</ToolTip>
                </Literal>
                <Literal>
                    <ID>count</ID>
                    <Default>1000</Default>
                    <ToolTip>The number of rows to select.</ToolTip>
                </Literal>
                <Literal>
                    <ID>where</ID>
                    <Default>1=1</Default>
                    <ToolTip>The WHERE clause.</ToolTip>
                </Literal>
            </Declarations>
            <!--
                The following tokens can be used in the Code element below:
                    $literal ID$ - The ID of a literal defined in the Declarations section above.
                                   If a literal is referenced multiple times, the first instance
                                   is editable and the value will be applied to all locations.
                    $selected$ - The selected text in the editor at the time a SurroundsWith snippet was inserted.
                    $end$ - The location for the caret after completion.
            -->
            <Code Language="sql">
<![CDATA[SELECT TOP $count$
    *
FROM
    $table$
WHERE
    $where$;

]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>
© 2002 - 2021 Atanasoft LLC. All rights reserved.