Creating raw SQL queries
Experienced SQL users can write their own SQL queries or copy and paste SQL queries from other applications. Writing raw SQL is an advanced operation; users are responsible for correct syntax and query results.
Procedure
- Begin configuring a Select or Segment process.
- For a Select process, you must switch to the Text Builder
in order to write a SQL query:
- Choose Select <audience> IDs With.
- Change to the Text Builder (instead of the default Point & Click method).
- Click Advanced.
- In the Advanced Settings dialog, check Use Raw SQL for Record Selection. This option enables the use of raw SQL in the Text Builder when you specify your selection criteria. If you do not select this option, you can only use IBM® EMM expressions and Custom Macros.
- Select a data source to query from the Database list. Select the target audience from the Audience Level list.
- If you want to run SQL commands before or after the Select process, you can specify raw SQL in the Pre-Processing or Post-Processing area. See Specifying pre- or post-processing SQL statements.
- Click OK to close the Advanced Settings dialog.
- Enter raw SQL in the text entry area. You can use the Formula Helper to help construct the SQL. Check SQL in the Formula Helper to restrict the list of operators and functions to SQL-specific options.
- For a Segment process:
- Choose Segment by Query, then create or edit a segment.
- Choose Select IDs With, click Text Builder, then click Advanced.
- In the Advanced Settings dialog, check Use Raw SQL, select a data source, and click OK.
- Enter raw SQL in the text entry area. Optionally, use the Formula Helper to help construct the SQL. Check SQL in the Formula Helper to restrict the list of operators and functions to SQL-specific options.
- Guidelines for using raw SQL queries
Writing raw SQL is an advanced operation; users are responsible for correct syntax and query results. - Hive query language conformance
The following guidelines apply when IBM Campaign is integrated with Hive-based big data sources. - Specifying pre- or post-processing SQL statements
If you are using a Select or Extract process, you can optionally include raw SQL statements to run before or after the process. - Using the TempTable and OutputTempTable tokens in raw SQL queries
Temporary tables provide a workspace for intermediate results when processing or passing data. When the operation is finished, temp tables are discarded automatically. - Referencing Extract tables in raw SQL queries
- How queries are evaluated in Campaign processes
Queries in Campaign processes are evaluated left to right using mathematical rules.
Parent topic: Using queries to select data