Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

On this Page

Table of Contents
maxLevel2
excludeOlder Versions|Additional Resources|Related Links|Related Information

Snap type:

Read

Description:

This Snap allows you to fetch data from a SQL Server database by providing a table name and configuring the connection. The Snap produces the records from the database on its output view which can then be processed by a downstream Snap. 

JSON paths can be used in a query and will have values from an incoming document substituted into the query. However, documents missing values for a given JSON path will be written to the Snap's error view. After a query is executed, the query's results are merged into the incoming document overwriting any existing keys' values. The original document is output if there are no results from the query.

Queries produced by the Snap have the format:

Code Block
SELECT [output fields] FROM [table] WHERE [where clause] ORDER BY [ordering] LIMIT [limit] OFFSET [offset]


Note
  • This Snap supports SQL Server 2008 or newer. 
  • The sub-millisecond time accuracy for all date/time data types is not supported.


If more powerful functionality is desired, then the Execute Snap should be used. 

  • Expected upstream Snaps: A dynamic where a clause can be defined by providing values upstream, such as the Mapper Snap can provide constants, pipeline parameters mapped into variables, which then can be used in the where clause or even in the table/schema properties.
  • Expected downstream Snaps: The Snap will output one document for every record retrieved, hence any document processing Snap can be used down stream.
  • Expected input: Document that provides values for one or more properties of the Snap or simply for pass through purpose.
  • Expected output: Document for each record retrieved. Special types such as TIMESTAMP, TIMESTAMPTZ and TIMESTAMPLTZ are converted into SnapLogic internal date type representations which then can be consumed by downstream Snaps just like any other data type.
Note

The where clause can only use variables, not constants or Pipeline parameters. 
A good example of a where clause is: SALARY =$SALARY (here we use the SALARY variable of the input document). 


Multiexcerpt macro
nameGetting Encrypted Data from the Database


Getting Encrypted Data from the Database
  • To get the values of the query result as plain text in the output, enter the following URL properties (Url property name and Url property value) in the SQL Server account that the Snap uses.

      columnEncryptionSetting: Enabled

  • If you have encryption columns that are created using java keystore, enter the following additional URL properties along with columnEncryptionSetting.

      keyStoreLocation: /path/to/jksfile

   keyStoreSecret: <password_used_to_create_jks>

   keyStoreAuthentication: JavaKeyStorePassword (fixed value)



Prerequisites:

None

Support and limitations:
  • Works in Ultra pipelines.
  • Pipelines fail in the execution mode whenever a value is set in Limit offset property.
Account: 

This Snap uses account references created on the Accounts page of SnapLogic Manager to handle access to this endpoint. See Configuring SQL Server Accounts for information on setting up this type of account.

Views:


Input

This Snap allows none or one input view. If the input view is defined, then the where clause can substitute incoming values for a given expression (in such as to use it as a lookup).

Output

This Snap has one output view by default and produces one document for each row in the table. A second view can be added to show the metadata for the table as a Document. The metadata document can then be fed into the second input view of SQL Server - Insert or Bulk Load Snap so that the table is created in SQL Server with a similar schema as the source table.

ErrorThis Snap has at most one error view and produces zero or more documents in the view.


Settings

Label

Required. The name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline.

Schema Name


The database schema name. In case it is not defined, then the suggestion for the Table Name will retrieve all tables names of all schemas. The property is suggestible and will retrieve available database schemas during suggest values.

ExampleSYS
Default value:  [None]

Table Name

Required. The table to execute the select query on.
Example: people

Default value: [None] 

Where clause 

The where clause of a select statement. This supports document value substitution (such as $person.firstname will be substituted with the value found in the incoming document at the path).

Examples

Multiexcerpt include macro
nameME_DB_Snaps_Query_Examples
pageOracle - Update

Order by

Enter in the columns in the order in which you want to order by. The default database sort order will be used.

Example:

name
email 

Default value: [None] 

Limit offset

Starting row for the query.

Example: 0

Default value: [None] 

Limit rows 

Number of rows to return from the query.

Example: 10

Default value: [None] 

Query Hints

Enter hints to customize and optimize the database engine in processing the query statement.

Note

Query hints that are supported are dependent on the SQL database version. For instance, SELECT * from sys.dm_exec_valid_use_hints query helps you list out the hints that are supported by a specific database.

ExampleOPTION (USE HINT ('DISABLE_OPTIMIZER_ROWGOAL'))

Default value: [None]

Output fields

Enter or select output fields for SQL SELECT statement. To select all fields, leave it at default.

Example: email, address, first, last, etc.

Default value: [None]

Fetch Output Fields In Schema

Insert excerpt
Cassandra - Select
Cassandra - Select
nopaneltrue

Default value: Not selected

Pass through

Select this checkbox to pass the input document to the output view under the key original

Default value: Selected

Ignore empty result

Enter or select output fields for SQL SELECT statement. To select all fields, leave it at default.

Example: email, address, first, last, etc.

Default value: Not Select this checkbox if you do not want to write to the output view when a SELECT operation does not produce any result or is empty. If you do not select this property and selected the Pass through property, the input document is passed through to the output view.

Default value: Not selected

Auto commit

Select one of the options for this property to override the state of the Auto commit property on the account. The Auto commit at the Snap-level has three values: TrueFalse, and Use account setting. The expected functionality for these modes are:

  •  True - The Snap will execute with auto-commit enabled regardless of the value set for Auto commit in the Account used by the Snap.
  •  False - The Snap will execute with auto-commit disabled regardless of the value set for Auto commit in the Account used by the Snap.
  • Use account setting - The Snap will execute with Auto commit property value inherited by the Account used by the Snap.

Default value: False

Number of retries

Specifies the maximum number of attempts to be made to receive a response. The request is terminated if the attempts do not result in a response.

Example: 3

Default value: 0

Multiexcerpt include macro
nameretries
pageFile Reader

Retry interval (seconds)

Specifies the time interval between two successive retry requests. A retry happens only when the previous attempt resulted in an exception. 

Example:  10

Default value: 1

Match data types

Conditional. This property applies only when the Output fields property is provided with any field value(s).

If this property is selected, the Snap tries to match the output data types same as when the Output fields property is empty (SELECT * FROM ...). The output preview would be in the same format as the one when SELECT * FROM is implied and all the contents of the table are displayed.

Default value: Not selected

Staging mode
Multiexcerpt include macro
nameStaging_mode_Description
pageGeneric JDBC - Select
Option for Unique Identifier Column

Conditional. This propery applies only when the Snap returns the unique identifier (GUID) in the output.

The unique identifier is stored in the database using an internal format and when it is displayed in the output, it is converted to a string and gets displayed in upper case for HEX characters. Select either of the following options to change the case type. Available options are:

  • Convert to lower case: Modifies the output string to lower case.

  • Convert to upper case: Modifies the output string to upper case.

Default Value: Convert to lower case

Example: Convert to upper case

Snap Execution


Select one of the three modes in which the Snap executes. Available options are:

  • Validate & Execute: Performs limited execution of the Snap, and generates a data preview during Pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during Pipeline runtime.
  • Execute only: Performs full execution of the Snap during Pipeline execution without generating preview data.
  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Examples


In this example, we will show how to retrieve data from a table called 'customer'.

Image Modified

We can pass the dynamic variable used in where clause from upstream Snap like JSON Generator. We try to retrieve customers by their name. 

Image Modified

The sample output looks like below:

Image Modified


Insert excerpt
SQL Server Snap Pack
SQL Server Snap Pack
nopaneltrue