开发者

SOQL Type conversion (SalesForce.com)

The problem is that I need to compare two fields of different types in a SOQL query.

TextField is a Picklist (so really text) and IntField is a Number(2, 0). Changing the types of these fields is not possible.

I would like to write SOQL like;

SELECT Id FROM SomeObject__c
WHERE Cast(TextField as Int开发者_StackOverflow社区eger) > IntField

Obviously Cast(TextField as Integer) does NOT work.

Any advise on type conversion within SOQL. The normal APEX functions (e.g. integer.valueof) don't seem to be of any help here.

Thanks


SOQL itself does not support casting but you can always lend a helping hand ;)

Create a Numeric formula field in SomeObject__c:

IF(ISNUMBER(TextField__c), VALUE(TextField__c), NULL)

or something similar depending on your definition of cast to int. Now you can use this field in a SOQL query.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜