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
sureshrk19sureshrk19 

no viable alternative at character '%'

Hi,

I'm facing problem having subquery.

Here is my query:

---------
QueryResult query = binding.query("select Title, "
    + " from ContentVersion v where "
    + "v.ContentDocumentId = '(select id from contentdocument c where c.latestpublishedversionid like \'<somevalue>%\')'");
 ----------

I tried couple other approaches to escape '%' but, no luck.

no viable alternative at character '%'  is the error I see on execution.

Did I miss anything?

Thanks,
Suresh

souvik9086souvik9086

Print the query  in system debug and see what comes and let know the query which is coming.

 

Thanks

sureshrk19sureshrk19

Hi Souvik,

 

Thanks for the pointers.

 

Not sure, If I'm missing something here but, let me briefly explain what I'm doing...

 

1/ My client application is using API from 'exterprise.wsdl' generated classes

2/ In my java program I'm using these APIs to login and download content from salesforce site

I have access to web portal only. I do not have access to backend server or salesforce logs.

 

I tried debugging my client flow but, no luck (as something is failing on server side).

 

Is there a way to look at logs/debug messages using API?

 

Thanks,

Suresh 

sbob909sbob909

SOQL supports the LIKE operator for string fields only. You cannot use LIKE '000%' with Id fields. See the documentation here:

 

http://www.salesforce.com/us/developer/docs/dbcom_soql_sosl/Content/sforce_api_calls_soql_select_comparisonoperators.htm

 

Please mark this as resolved.

 

Steve

sureshrk19sureshrk19

Steve,

 

'latestpublishedversionid' is varchar field. 

 

And the query I'm trying is working fine from SQL shell

 

------------

select Title, "
    + " from ContentVersion v where "
    + "v.ContentDocumentId = '(select id from contentdocument c where c.latestpublishedversionid like \'<somevalue>%\')';

--------------

 

As per the document link shared, the query tried by me should be well formed.

 

Thanks,

Suresh

 

sbob909sbob909

When I look at the metadata for the ContentDocument.LatestPublishedVersionId field in Workbench, I see that the field type is "reference", which indicates to me that it is an Id field. 

DhanalakshmiDhanalakshmi
Suresh
Any solution you found for the issue your reported? Thanks in Adv

Satish