SOQL 类型转换 (SalesForce.com) [英] SOQL Type conversion (SalesForce.com)

查看:69
本文介绍了SOQL 类型转换 (SalesForce.com)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是我需要在 SOQL 查询中比较两个不同类型的字段.

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

TextField 是一个选择列表(所以真的是文本),而 IntField 是一个 Number(2, 0).无法更改这些字段的类型.

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

我想写 SOQL 之类的;

I would like to write SOQL like;

SELECT Id FROM SomeObject__c
WHERE Cast(TextField as Integer) > IntField

显然 Cast(TextField as Integer) 不起作用.

关于 SOQL 中类型转换的任何建议.正常的 APEX 函数(例如 integer.valueof)在这里似乎没有任何帮助.

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

谢谢

推荐答案

SOQL 本身不支持强制转换,但您可以随时伸出援助之手 ;)

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

SomeObject__c中创建一个数字公式字段:

Create a Numeric formula field in SomeObject__c:

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

或类似的东西,取决于您对强制转换为 int 的定义.现在您可以在 SOQL 查询中使用此字段.

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

这篇关于SOQL 类型转换 (SalesForce.com)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆