Table of Contents

Search

  1. Preface
  2. Mappings
  3. Mapplets
  4. Mapping Parameters
  5. Mapping Outputs
  6. Generate a Mapping from an SQL Query
  7. Dynamic Mappings
  8. How to Develop and Run a Dynamic Mapping
  9. Dynamic Mapping Use Cases
  10. Mapping Administration
  11. Export to PowerCenter
  12. Import From PowerCenter
  13. Performance Tuning
  14. Pushdown Optimization
  15. Partitioned Mappings
  16. Developer Tool Naming Conventions

Developer Mapping Guide

Developer Mapping Guide

String Parameters in SQL Statements

String Parameters in SQL Statements

When you define a string parameter in an SQL statement, you must add single quotes
(' ')
to the parameter in the query. If single quotes are part of the default value instead of the query, the Data Integration Service escapes the data in each parameter with single quotes and adds additional single quotes for every single quote that appears in the default value.

Example - Single Quotes in the Query

For example, you have an SQL statement with a date parameter $date_parm. The SQL statement appears as the following expression:
select * from <table_name> where <date_port> > $date_parm
Since the parameter $date_parm is a string, add single quotes to the parameter in the query. The following expression shows the query where single quotes are added to the parameter:
select * from <table_name> where <date_port> > '$date_parm'
If the default value of the parameter $date_parm is
01/31/2000 00:00:00
, the following expression shows how the Data Integration Service expands the query:
select * from <table_name> where <date_port> > '01/31/2000 00:00:00'

Example - Single Quotes in the Default Value

You use the same SQL statement with a date parameter $date_parm. The SQL statement appears as the following expression:
select * from <table_name> where <date_port> > $date_parm
You add single quotes to the default value
'01/31/2000 00:00:00'
. The following expression shows the expanded query:
select * from <table_name> where <date_port> > ''01/31/2000 00:00:00''
Since single quotes are part of the default value, the Data Integration Service escapes the data with additional single quotes. Because the string parameter contains double quotes in the expanded query, the query might fail or produce no result.

0 COMMENTS

We’d like to hear from you!