最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

guidewire - How to convert complex SQL Query in Gosu Query API? - Stack Overflow

programmeradmin1浏览0评论

In PolicyCenter on-premise we could use this SQL query to address a certain problem. I wonder how to tranform it into a Gosu Query now that we use the cloud version of PolicyCenter :

SELECT contactId, ADDRESSTYPE
FROM (
SELECT c.ID AS contactID, a.CREATETIME, a.VALIDFROM, a.ADDRESSTYPE
FROM WPC.PC_CONTACT c
JOIN WPC.PC_ADDRESS a ON c.PRIMARYADDRESSID = a.ID
UNION ALL
SELECT ca.contactID AS ContactID, a.CREATETIME, a.VALIDFROM, a.ADDRESSTYPE
FROM WPC.PC_CONTACTADDRESS ca
JOIN WPC.PC_ADDRESS a ON ca.ADDRESSID= a.ID
)
GROUP BY contactID, VALIDFROM, ADDRESSTYPE
HAVING COUNT(VALIDFROM) >= 2;

I tried a lot of joinings, unions etc... But i can't manage to get it to do the same ! Thank you for any help given !

In PolicyCenter on-premise we could use this SQL query to address a certain problem. I wonder how to tranform it into a Gosu Query now that we use the cloud version of PolicyCenter :

SELECT contactId, ADDRESSTYPE
FROM (
SELECT c.ID AS contactID, a.CREATETIME, a.VALIDFROM, a.ADDRESSTYPE
FROM WPC.PC_CONTACT c
JOIN WPC.PC_ADDRESS a ON c.PRIMARYADDRESSID = a.ID
UNION ALL
SELECT ca.contactID AS ContactID, a.CREATETIME, a.VALIDFROM, a.ADDRESSTYPE
FROM WPC.PC_CONTACTADDRESS ca
JOIN WPC.PC_ADDRESS a ON ca.ADDRESSID= a.ID
)
GROUP BY contactID, VALIDFROM, ADDRESSTYPE
HAVING COUNT(VALIDFROM) >= 2;

I tried a lot of joinings, unions etc... But i can't manage to get it to do the same ! Thank you for any help given !

Share Improve this question edited Feb 7 at 19:18 Timothée Auffret asked Feb 7 at 19:16 Timothée AuffretTimothée Auffret 33 bronze badges New contributor Timothée Auffret is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. 1
  • What problem was that query solving? Maybe your query rewritten so that it is implemented with the gosu query API easier – Sergio Commented yesterday
Add a comment  | 

1 Answer 1

Reset to default 1

I think you would need to pass the union call as an argument to a subselect which Guidewire says is not allowed:

Note: You cannot use the union method on query objects passed as arguments to the subselect method.

https://docs.guidewire.com/cloud/pc/202411/integration/integration/topics/querybuilderapi/c_ba3266101.html

This might be one of those fun instances that does not have a way to accomplish strictly using a query API call. It certainly would not be as efficient, but you could do both queries and then determine if 2 or more results were returned in gosu code since you are coding it in gosu anyway.

What do you use the results for? Is this a query that you run, get the results, and then take some other action outside of PC? If optimal performance is not important, I would just write this with a combination of query API calls and gosu code and not worry about recreating this SQL query exactly using a query API call.

发布评论

评论列表(0)

  1. 暂无评论