在 Oracle 9.2 中,如何将包含字符串文本的 LONG 类型与 VARCHAR2 的列进行比较

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/501625/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 17:44:32  来源:igfitidea点击:

in Oracle 9.2, how to compare LONG Type containing String text to a Column of VARCHAR2

oraclestringtypes

提问by

simple q. in Oracle 9.2, how to compare LONG Type containing String text to a Column of VARCHAR2.

简单的q。在 Oracle 9.2 中,如何将包含 String 文本的 LONG 类型与 VARCHAR2 的列进行比较。

select * from table1 t1, table2 t2 where t1.long_value = t2.varchar2_value

select * from table1 t1, table2 t2 where t1.long_value = t2.varchar2_value

how can i execute such a query the easiest way?

我怎样才能以最简单的方式执行这样的查询?

回答by DCookie

The short answer is you can't, directly. Have a look at thisfor a function to convert longs to varchar2 so you can use it in a SQL statement. LONG is more trouble than it's worth, but sometimes you're stuck with it.

简短的回答是你不能直接。看看这个将 longs 转换为 varchar2 的函数,以便您可以在 SQL 语句中使用它。LONG 比它的价值更麻烦,但有时你会被它困住。

回答by John Nilsson

hmm, without having Oracle accesible I'm guessing your problem is with casting to the correct types.

嗯,没有 Oracle 可访问我猜你的问题是转换为正确的类型。

try (''||t1.long_value) = t2.varchar2_valueto force a conversion

尝试(''||t1.long_value) = t2.varchar2_value强制转换

but it depends on how you have your indexes setup. If you want to utilize the index on t1.long_value you may be better of converting t2.varchar2_value to something

但这取决于您如何设置索引。如果您想利用 t1.long_value 上的索引,最好将 t2.varchar2_value 转换为某些内容