Salesforce

How Do I Create an SQL Statement Without Using the Data Mapper`s Database Wizard? (Magic xpi 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Create an SQL Statement Without Using the Data Mapper’s Database Wizard?

The Magic xpi Data Mapper service provides a wizard to quickly build a simple SQL statement to use when mapping data. To increase development flexibility, you can manually create an SQL statement without using the wizard.

To manually create an SQL statement, drag the Data Mapper Service to a flow. In the Source Destination dialog box, select Database as your Source or Destination, then click Properties to open the Database Schema Properties dialog box. Run the wizard to select the table and columns you need. The next time you enter the Database Schema Properties, click SQL at the bottom of the dialog box to open the SQL Statement screen. Use basic database script rules to enter an SQL statement in the SQL Statement field. If the current object is a Source data object, only a Select statement is allowed. If the current object is a Destination data object, then only Update, Insert and Delete statements are allowed.

When a Flow Variable is entered, it will be surrounded by elbow brackets and question marks as follows: <?flow variable name?>. You can also write other legal SQL statement text, such as Example or Order By.

You can use multiple tables in the statement, with a JOIN between them—or if multiple tables were selected through the wizard, a JOIN will be automatically created according to the selections made in the wizard.

Data Mapper Service SQL Statement Considerations

  • Use ANSI symbols in the statement for support of all Database types.

  • The Data Mapper Service does not support unions. They will not be present in the visual mapper.

  • The Data Mapper does not support field names with spaces.

  • You must enclose all Alpha strings with single quotes (').

  • To connect to other databases, you must indicate the database owner. You do not need to indicate the owner if the database you want to connect to is the Magic xpi internal database that you are using for your project.

  • You cannot use wildcards for fields or functions. You must specify each one or create an alias for them.

Example

This example explains how to update the following table by creating a manual SQL statement (without using the Data Mapper Service’s wizard).

Table_Key

Col1

Col2

Col3

1

A

12

F

2

B

14

Y

3

C

18

W

To add a numeric variable called My_Key:

  1. Open an existing flow or create a new flow and drag the Data Mapper Service to the flow.

  2. In the Source/Destination Properties dialog box, Destination column select Database.

  3. Click Properties (on the Destination side).

  4. Select Update as the Database Operation and Database Definition.

  5. Click Wizard and run the wizard.

  6. Click Properties (on the Destination side).

  7. Click SQL to open the SQL Statement screen.

  8. Write the following statement:


UPDATE ExampleTable SET ExampleTable.Col1=’T’, ExampleTable.Col2=20, ExampleTable.Col3=’X’, WHERE ExampleTable.Table_Key=<!?My_Key?!>

The record that is updated is determined by the value of the My_Key numeric variable. The table columns are updated with the following values:

  • Col1: T

  • Col2: 20

  • Col3: X

Reference
Attachment 
Attachment