有人可以用 sql 或 teradata 帮我验证一下吗
我在 Oracle 中有一行代码,我必须将其转换为 Teradata。 Oracle 查询是
/* add to avoid invalid number due to junk in column */
AND regexp_instr(table.column, ''[^[:digit:]]'', 1, 1) = 0
我在 Teradata 中编写的代码。
AND (CASE WHEN (POSITION('' '' IN TRIM(table.column)) > 0) OR (UPPER(TRIM(table.column))
(CASESPECIFIC) <> LOWER(TRIM(table.column)) (CASESPECIFIC))
THEN 1 ELSE 0 end ) = 0
该列定义为 VARCHAR(20) ,但我只想选择数据均为数字的行。我无法验证 Teradata 查询,因为它是一个运行时间非常长的查询,并且我无权创建表,或者更确切地说,我无法验证我拥有的数据库的输出。我尝试过一些方法,看起来确实有效,但我曾经想验证语法和我对 REGEXP_INSTR 的理解。
I have a line of code in Oracle and I had to convert it into Teradata.
The Oracle query is
/* add to avoid invalid number due to junk in column */
AND regexp_instr(table.column, ''[^[:digit:]]'', 1, 1) = 0
The code I have written in Teradata
AND (CASE WHEN (POSITION('' '' IN TRIM(table.column)) > 0) OR (UPPER(TRIM(table.column))
(CASESPECIFIC) <> LOWER(TRIM(table.column)) (CASESPECIFIC))
THEN 1 ELSE 0 end ) = 0
The column is defined as a VARCHAR(20)
but I only want to select rows where the data is all numeric. I cannot verify the Teradata query as it is a very long-running query and I don't have access to create tables or rather I can not verify the out put on the database I have. I some how tried and it looks like it works but I once wanted to verify the syntax and my understanding of REGEXP_INSTR.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我阅读正确并且根据我的测试,这将破坏您的逻辑(均返回 1):
Teradata Developer's Exchange 包含一个已转换为 Teradata UDF 的 Oracle 函数库,可以帮助您解决此问题。只需付出一点努力,您就可以围绕
isdigit()
C 函数编写自己的 UDF。 (isdigit)现在可能没有帮助,但是最近宣布的 Teradata 14.0 功能之一是支持正则表达式。
编辑:添加了带有 REGEXP_INSTR 的 TD 14 示例,应该可以解决问题
If I am reading correctly and based on my testing this will break your logic (both return 1):
The Teradata Developer's Exchange contains a library of Oracle functions that have been converted to Teradata UDF's that may help you address this problem. With a little effort you could write your own UDF around the
isdigit()
C function. (isdigit)It may not be helpful now, but one of the recently announced Teradata 14.0 features is support of regular expressions.
EDIT: Added TD 14 example with REGEXP_INSTR that should solve the problem