English 中文(简体)
如何查询Oracle的CLOB一栏
原标题:How to query a CLOB column in Oracle

I m 试图管理一个小栏,即CLOB数据型。 如果一如正常,上述所有领域都将<代码>(CLOB)作为数值。

I Trial using DBMS_LOB.substr(column) and i Expo the wrong

ORA-06502: PL/SQL: numeric or value error: character string buffer too small

• 如何查询联络处栏目?

最佳回答

有时,在获得CLOB一栏的分数时,使用有大小/差别限制的查询工具,你需要将BUFFER设定到更大的规模。 例如,在使用SQ+时使用SET BUFFER 10000,将其设定为10 000,因为违约为4 000。

操作<代码>DBMS_LOB.substr 指示你也能够具体说明你想要返回的品格,以及从中减去的数额。 因此,如果使用DBMS_LOB.substr(column, 3000),则可能将其限制在足够小的范围内进行缓冲。

oracle documentation,用于更多次指挥信息


    DBMS_LOB.SUBSTR (
       lob_loc     IN    CLOB   CHARACTER SET ANY_CS,
       amount      IN    INTEGER := 32767,
       offset      IN    INTEGER := 1)
      RETURN VARCHAR2 CHARACTER SET lob_loc%CHARSET;

问题回答

著作

select DBMS_LOB.substr(myColumn, 3000) from myTable

我确实在我的Oracle数据库中与HugeClob一道陷入另一个状态。 <代码>dbms_lob.substr 仅允许在职能中达到4 000美元的价值:

dbms_lob.substr(column,4000,1)

因此,对于规模较大的我的HughClob,我不得不在<条形码>上使用两条电话:<<> > >

select dbms_lob.substr(column,4000,1) part1, 
       dbms_lob.substr(column,4000,4001) part2 from .....

我从 Java叫.,我只是把第1部分和第2部分混为一谈,并作为电子邮件发出。

如果它带有一个CLOB,那么我们为什么会把一栏_起来,然后通常进行搜索?

编制表格

CREATE TABLE MY_TABLE(Id integer PRIMARY KEY, Name varchar2(20), message clob);

本表创建少数记录

INSERT INTO MY_TABLE VALUES(1, Tom , Hi This is Row one );
INSERT INTO MY_TABLE VALUES(2, Lucy ,  Hi This is Row two );
INSERT INTO MY_TABLE VALUES(3, Frank ,  Hi This is Row three );
INSERT INTO MY_TABLE VALUES(4, Jane ,  Hi This is Row four );
INSERT INTO MY_TABLE VALUES(5, Robert ,  Hi This is Row five );
COMMIT;

在布列栏搜索

SELECT * FROM MY_TABLE where to_char(message) like  %e% ;

成果

ID   NAME    MESSAGE   
===============================  
1    Tom     Hi This is Row one         
3    Frank   Hi This is Row three
5    Robert  Hi This is Row five

对大的CLOB选择也可使用:

SlectT dbms_lob.substr(一栏:名称、dbms_lob.getlength (column_name), (1) 来源:

另一种选择是,每当你需要选择布列栏时,就设立一个职能,并称这一职能。

create or replace function clob_to_char_func
(clob_column in CLOB,
 for_how_many_bytes in NUMBER,
 from_which_byte in NUMBER)
return VARCHAR2
is
begin
Return substrb(dbms_lob.substr(clob_column
                            ,for_how_many_bytes
                            ,from_which_byte)
            ,1
            ,for_how_many_bytes);
end;

将这一职能称为:

SELECT tocharvalue, clob_to_char_func(tocharvalue, 1, 9999)
FROM (SELECT clob_column AS tocharvalue FROM table_name);

回答。

declare
v_result clob;
begin
---- some operation on v_result
dbms_lob.substr( v_result, 4000 ,length(v_result) - 3999 );

end;
/

<代码>dbms_lob.substr

<代码>第二段参数是你希望提取的衣物长度。

<编码> 第三参数是你希望从中提取的。

在上述例子中,我知道我的衣着面积超过5 000万,因此,我想要达到4 000个特性。





相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

How to make a one to one left outer join?

I was wondering, is there a way to make a kind of one to one left outer join: I need a join that matches say table A with table B, for each record on table A it must search for its pair on table B, ...

Insert if not exists Oracle

I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL ...

How can I store NULLs in NOT NULL field?

I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...

Type reference scope

I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

热门标签