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).
|
---|
Prerequisites: | None
|
---|
Support and limitations: |
|
---|
Account: | This Snap uses account references created on the Accounts page of SnapLogic Manager to handle access to this endpoint. See SQL Server Account 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. |
---|
Error | This 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. Example: SYS 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). Example: email = 'you@example.com' or email = $email
|
---|
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 |
---|
Enter or select the JSON path of the lookup column value. The value will be provided by the input data field.Example: $email, $first, $lastStarting row for the query. Example: 0 Default value: |
Enter or select the lookup column nameNumber of rows to return from the query. Example: |
email, first, last [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]
|
---|
Pass through | If selected, the input document will be passed through 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: [None]
|
---|
Examples
...
In this example, we will show how to retrieve data from a table called 'customer'.
...