如果选择查询,如何选择长列
我有一个表,该表的列是数据类型长的。如果我编写一个基本查询来获取那个长colmun的值,我会得到适当的结果。 例如:
select long_text from fnd_documents_long_text;
这返回适当的价值。
但是,如果我尝试将案例语句与长列一起使用,则它给出了ORA-00997:长期数据类型错误的非法使用。 我正在尝试编写以下查询:
select case when datatype_id = 2 then
( select long_text from fnd_documents_long_text where media_id= fd.media_id) end Text
from fnd_documents fd where document_id = 715193;
您能建议您如何在选定查询中的案例语句中检索长列的值。
我真正想要的是,如果datatype_id = 1,那么,从fnd_documents_short_text表获取short_text,如果datatype_id是2,则获取long_text,从fnd_documents_long_text表中获取long_text,其中“ long_text”是dataType的“ long_text”。这些是标准的Oracle应用表。我正在写下我的查询
select case when datatype_id = 1 then ( select short_text from fnd_documents_short_text where media_id =fd.media_id)
when datatype_id = 2 then ( select long_text from fnd_documents_long_text where media_id =fd.media_id)
end Text
from fnd_documents fd where document_id = 715193 ;
。 阿巴
I have a table which has a column of datatype LONG. If I write a basic query to fetch the value of that LONG colmun, I get the proper results.
For eg:
select long_text from fnd_documents_long_text;
This returns proper value.
But If, I try to use a case statement with the LONG column, it gives ORA-00997: Illegal use of LONG datatype error.
I am trying to write the below query :
select case when datatype_id = 2 then
( select long_text from fnd_documents_long_text where media_id= fd.media_id) end Text
from fnd_documents fd where document_id = 715193;
Can you please suggest how can I retrieve the value of LONG column inside a case statement in Select query.
What i really want is that if the datatype_id =1 then, get the short_text from fnd_documents_short_text table else if datatype_id is 2 then get the long_text from fnd_documents_long_text table, where "long_text" is of datatype LONG. These are standard Oracle APPs tables. I am writing my query as below..but it is not working fine:
select case when datatype_id = 1 then ( select short_text from fnd_documents_short_text where media_id =fd.media_id)
when datatype_id = 2 then ( select long_text from fnd_documents_long_text where media_id =fd.media_id)
end Text
from fnd_documents fd where document_id = 715193 ;
Thanks,
abha
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如建议的在这里您可以使用全球临时表
first insert 临时表中表的相关部分(记录)。您可以根据需要从中选择它,因为临时表中的两个列具有相同的类型 -
clob
。您无需从温度删除。表,
提交
将做到这一点。示例
失败:
但是在临时表中复制数据工作
As proposed here you may workaround using a global temporary table
First insert the relevant part (record) of your table in the temporary table. Than you can select from it as required, because both columns in teh temporary table have same type -
CLOB
.You need not to delete from the temp. table, a
COMMIT
will do it.Example
This fails:
But copying data in temporary table works
有很多限制
长
数据类型,它宁愿限制您的选项。作为方案的一种可能的解决方法,您可以创建一个将
long
值查询到本地变量的函数,然后将其返回为clob
,例如:然后在您的情况下。表达式您可以调用该函数:
或用左外连接到“短”表,而不是使用子查询:
“ noreflowl noreferrer”> db<
从Oracle 12C中,您甚至可以将功能声明为CTE的一部分,因此您不需要永久数据库对象(尽管您可能会经常这样做,但您可能会这样做):
There are a lot of restrictions on the
LONG
data type, which rather limits your options.As one possible workaround for your scenario, you could create a function that queries the
LONG
value into a local variable and then returns it as aCLOB
, e.g.:Then in your case expression you can call that function:
or with a left outer join to the 'short' table instead of using a subquery:
db<>fiddle demo.
And from Oracle 12c you can even declare the function as part of a CTE, so you don't need a permanent database object (though you probably do if you'll be doing this often):
为什么不只是加入?
如果您想使用案例/加入查询,可以执行此操作:
Why not doing just a Join ?
If you want to use a case/join query, you can do this :