这意味着你的查询没有返回结果(所以列表是空的,然后当投入Sobject时,没有物品需要)。
qName = [select Row_Id__c, Name from Ccon__c where Id = :ApexPages.currentPage().getParameters().get('id')].Row_Id__c;
我会做这种方式(以确保在任何情况下,我会从我的查询中获取价值,如果我的ID是有效的):
Id tempID = null;
if(ApexPages.currentPage().getParameters().get('id') != null)
{
tempId = ApexPages.currentPage().getParameters().get('id');
}
else{ //Error management
}
List<Ccon__c> recordsToProcess = new List<Ccon__c>();
if(tempID != null)
{
recordsToProcess = [select Row_Id__c, Name from Ccon__c where Id = :tempID];
}
else{ //Error management
}
//qName Declaration
if(!recordsToProcess.isEmpty())
{
qName = recordsToProcess[0].Row_Id__c;
}
else{ //Error management
}
if(qName == null)
{
//Error management
}
如果您有更多疑问,请随时向问。但作为一种最佳实践,您可能始终确保您的列表在获取记录返回之前不是空的。
谢谢 HqSeO