SOQL 类型转换 (SalesForce.com)
问题是我需要在 SOQL 查询中比较两个不同类型的字段。
TextField 是一个 Picklist(实际上是文本),IntField 是一个 Number(2, 0)。更改这些字段的类型是不可能的。
我想写 SOQL 像;
SELECT Id FROM SomeObject__c
WHERE Cast(TextField as Integer) > IntField
显然 Cast(TextField as Integer)
不起作用。
关于 SOQL 中类型转换的任何建议。普通的 APEX 函数(例如integer.valueof)在这里似乎没有任何帮助。
谢谢
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 Integer) > 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SOQL 本身不支持强制转换,但您始终可以伸出援手;)
在
SomeObject__c
中创建一个数字公式字段:或类似的内容,具体取决于您对强制转换为 int 的定义。现在您可以在 SOQL 查询中使用该字段。
SOQL itself does not support casting but you can always lend a helping hand ;)
Create a Numeric formula field in
SomeObject__c
:or something similar depending on your definition of cast to int. Now you can use this field in a SOQL query.