5

When I execute SOQL in Developer Console:

Select Id, Amount From Opportunity Where Amount > 10000000000

An parsing error occurs:

Unknown error parsing query

Is there length limit of number on SOQL Where condition?

1
  • 1
    Funny enough the query will work if you added ".0" at the end to be 10000000000.0 Jan 19, 2016 at 5:53

3 Answers 3

8

According to your query you are passing 10000000000 which is a 11 digit Integer value.

In Salesforce or Java Integer can not be bigger than 2,147,483,647. Current value you are passing is considered as Integer and exceeds the given number so error is given.

Try adding decimal. Decimal can be bigger upto 2 raise to power 63 - 1. So this will work:

Select Id, Amount From Opportunity Where Amount > 10000000000.0

Compiler will understand that it is a decimal.

3

As per document ..

Maximum number we can use is 2,147,483,647.

Integer

A 32-bit number that does not include a decimal point. Integers have a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647. For example:

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_primitives.htm

3

I am having an alternate method

You can use the Long datatype to solve this problem.

For Example:

Select Id, Amount From Opportunity Where Amount > 10000000000L

We are now explicitly telling the compiler the amount is the Long Datatype.

The Long datatype in Salesforce and Java has a much larger range than the Integer datatype and can hold values up to 9,223,372,036,854,775,807.

By adding the suffix "L" to the end of the number in the WHERE clause, you are telling the compiler to treat the number as a Long value.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .