Newer Version Available
SQL Configuration
| Available in: Salesforce Classic (not available in all orgs) and Lightning Experience |
| Available in: Enterprise, Performance, Unlimited, Developer, and Database.com Editions |
When running Data Loader in batch mode from the command line, the SqlConfig class contains configuration parameters for accessing specific data in the database. As shown in the code samples below, queries and inserts are different but very similar. The bean must be of type com.salesforce.dataloader.dao.database.SqlConfig and have the following properties:
- sqlString
- The SQL code to be used by the data access object.
The SQL can contain replacement parameters that make the string dependent on configuration or operation variables. Replacement parameters must be delimited on both sides by “@” characters. For example, @process.lastRunDate@.
- sqlParams
- A property of type map that contains descriptions of the replacement parameters specified in sqlString. Each entry represents one replacement parameter: the key is the replacement parameter's name, the value is the fully qualified Java type to be used when the parameter is set on the SQL statement. Note that “java.sql” types are sometimes required, such as java.sql.Date instead of java.util.Date. For more information, see the official JDBC API documentation.
- columnNames
- Used when queries (SELECT statements) return a JDBC ResultSet. Contains column names for the data outputted by executing the SQL. The column names are used to access and return the output to the caller of the DataReader interface.
SQL Query Bean Example
1<bean id="accountMasterSql"
2 class="com.salesforce.dataloader.dao.database.SqlConfig"
3 singleton="true">
4 <property name="sqlString"/>
5 <value>
6 SELECT distinct
7 '012x00000000Ij7' recordTypeId,
8 accounts.account_number,
9 org.organization_name,
10 concat (concat(parties.address1, ' '), parties.address2) billing_address,
11 locs.city,
12 locs.postal_code,
13 locs.state,
14 locs.country,
15 parties.sic_code
16 from
17 ar.hz_cust_accounts accounts,
18 ar.hz_organization_profiles org,
19 ar.hz_parties parties,
20 ar.hz_party_sites party_sites,
21 ar.hz_locations locs
22 where
23 accounts.PARTY_ID = org.PARTY_ID
24 and parties.PARTY_ID = accounts.PARTY_ID
25 and party_sites.PARTY_ID = accounts.PARTY_ID
26 and locs.LOCATION_ID = party_sites.LOCATION_ID
27 and (locs.last_update_date > @process.lastRunDate@ OR accounts.last_update_date > @process.lastRunDate@
28 </value>
29 </property>
30 <property name="columNames">
31 <list>
32 <value>recordTypeId</value>
33 <value>account_number</value>
34 <value>organization_name</value>
35 <value>billing_address</value>
36 <value>city</value>
37 <value>postal_code</value>
38 <value>state</value>
39 <value>country</value>
40 <value>sic_code</value>
41 </list>
42 </property>
43 <property name="sqlParams">
44 <map>
45 <entry key="process.lastRunDate" value="java.sql.Date"/>
46 </map>
47 </property>
48</bean>SQL Insert Bean Example
1<bean id="partiesInsertSql"
2 class="com.salesforce.dataloader.dao.database.SqlConfig"
3 singleton="true">
4 <property name="sqlString"/>
5 <value>
6 INSERT INTO REP.INT_PARTIES (
7 BILLING_ADDRESS, SIC_CODE)
8 VALUES (@billing_address@, @sic_code@)
9 </value>
10 </property>
11 <property name="sqlParams"/>
12 <map>
13 <entry key="billing_address" value="java.lang.String"/>
14 <entry key="sic_code" value="java.lang.String"/>
15 </map>
16 </property>
17</bean>