function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
eblazereblazer 

Data Loader: Command Line w/ SQL & "@" Characters

Hello,

I'm using Data Loader 11.0 from the command line. Is there a proper escape sequence for "@" characters within SQL statements to keep Data Loader from interpreting them as variables?

For example:

SELECT 'eblazer@somewhere.com' AS emailaddress, accountid FROM contacts

The above is perfectly valid SQL, however Data Loader encounters the "@" symbol and does something to break the SQL and a JDBC exception is thrown.

As a temporary work around, i've been changing the SQL as follows:

SELECT 'eblazer' + char(64) + 'somewhere.com' AS emailaddress, accountid FROM contacts

Thanks,

Eddie
NasipuriNasipuri
Hi Eddile,
 
 You can not pass a SQL to the Data loader .
 You have to write an SOQL (Salesforce Object Query Language) and have to pass it to Data Loader.
 
I think the proper SOQL will be like below
 

Select Name , AccountId , Email From Contact WHERE email='dinesh.nasipuri@gmail.com'

I think this will help you.

Thanks and Regards,

Dinesh Nasipuri

dinesh.nasipuri@gmail.com

 

eblazereblazer
Hi Dinesh,

I think you might be mis-understanding the scenario. Using DataLoader's command line interface (aka "Running in Batch Mode"), you can send a SQL (not SOQL!) statement to any JDBC-compatible database. DataLoader will retrieve the result set, parse it, and insert/upsert/update the data to Salesforce.com.

Before executing the SQL statement, DataLoader can search for, and replace, variables within the SQL statement. These variables are denoted with an @ symbol. Example:

SELECT Id, FirstName, LastName
FROM MyContacts
WHERE InsertDate > @process.lastRunDate@

Will retrieve all contacts (from my JDBC database) inserted into "MyContacts" since the last time the DataLoader batch process has been executed, and then insert/upsert/update into Salesforce.com.

My problem occurs when I need to execute a SQL statement that has a legitimate "@" symbol in the SQL. Example:

SELECT Id, FirstName, LastName, 'eblazer@somewhere.com' AS Email
FROM MyContacts

DataLoader encounters the "@" in "eblazer@somewhere.com", thinks it's a variable, and for some reason after realizing it's not a valid variable strips the "@somewhere.com" thereby making the SQL Statement invalid and throwing an exception.

I'd like to know if there is a way to 'escape' the @ symbol to keep dataloader from parsing it as a variable.

Thanks.

Jay_blueJay_blue
eblazer,

Take a look at the data loader user guide, p23 it explains how the replacement parameters can be used.

I am not quite sure what you are ultimately trying to do, the example you provided is legite in SQL, but you have to use SOQL when using the dataloader.
Your example:

SELECT 'eblazer@somewhere.com' AS emailaddress, AccountId From Contact

Simply states that you want to provide a default value, if that is actaully what you want to do, you can to that in a mapping file.

Hope that helps.