SQLCode=-138 flagging on large count tables but not small DB2

二次信任 提交于 2019-12-25 09:35:07

问题


I built a view in which I'm using the following code to pull only the Last name from a field that is formatted 'LastName,FirstName':

VALUE(RTRIM(SUBSTR(A.PREVIOUS_NAMES,1,LOCATE(',', A.PREVIOUS_NAMES)-1)), '') 
AS "PREVIOUS_NAME",                                                         

This view worked fine as I was working in our sandbox environment, but as I moved it up to test, and try to open the view in DBVisualizer, the data results provide the Error:

THE SECOND OR THIRD ARGUMENT OF THE SUBSTR OR SUBSTRING FUNCTION IS OUT OF 
RANGE. SQLCODE=-138, SQLSTATE=22011, DRIVER=4.22.29

The sandbox has just under 11k records, where the test and prod systems are closer to 1.2 million, so I'm guessing this is a performance issue as a result of complexity of that piece of the code. The view still appears to have been created, I can query it and return a specific result/set of results, I guess I'm concerned on if it is usable for a large query, or if performance really is a concern in this case?

Is there a better way I can parse that last name without having to use the substring on a locate function?

Thanks for the help!


回答1:


Most likely it is not a performance issue, just some rows have data with no comma



来源:https://stackoverflow.com/questions/46204938/sqlcode-138-flagging-on-large-count-tables-but-not-small-db2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!