[英]How to search for a string in a CLOB and display the value after it in Oracle SQL?
[英]How to reverse value of a clob data type in oracle sql?
我想像在``反向''功能的幫助下以與字符串數據類型字段相同的方式來反向Oracle中的Clob數據類型值。是否有任何內置方法.Google並沒有太大幫助。在sql中成為新手不知道是否有可能? 我最初以為'reverse'函數也可以用於clob數據類型字段,但是它不起作用,這是我嘗試過的示例-
drop table test;
create table test
(
name varchar2(4000),
description clob
)
insert into test values ('aadinath','I have to reverse a clob data type value')
select reverse(name) from test;
輸出= htanidaa
select reverse(name), reverse(description) from test;
輸出= ORA-00932:數據類型不一致:預期的CHAR獲得CLOB00932。00000-“數據類型不一致:預期的%s獲得了%s”
您需要先將clob
convert
為varchar2
。 然后執行reverse
。
將CLOB數據類型轉換為varchar()的函數是DBMS_LOB。 DBMS_LOB包提供了可在BLOB,CLOB,NCLOB,BFILE和臨時LOB上運行的子程序。 您可以使用DBMS_LOB訪問和操作LOB的特定部分或完整的LOB。 DBMS_LOB可以讀取和修改BLOB,CLOB和NCLOB。 它為BFILE提供只讀操作。
句法:
DBMS_LOB.SUBSTR (lob_loc, amount, offset)
dbms_lob.substr( clob_column, for_how_many_bytes, from_which_byte );
參數說明:
例:
CREATE OR REPLACE VIEW temp_view
AS
SELECT
column1, -- datatype numeric
column2, -- datatype varchar()
DBMS_LOB.SUBSTR(column3, 2000,1) as column3, -- datatype CLOB
column4 -- datatype numeric
FROM temp_table;
注意:在此示例中,我正在閱讀前2000個字符。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.