How to query a CLOB column in Oracle

前端 未结 8 1446
鱼传尺愫
鱼传尺愫 2020-11-27 06:24

I\'m trying to run a query that has a few columns that are a CLOB datatype. If i run the query like normal, all of those fields just have (CLOB) as the value.

相关标签:
8条回答
  • 2020-11-27 06:49

    If you are using SQL*Plus try the following...

    set long 8000
    
    select ...
    
    0 讨论(0)
  • 2020-11-27 06:55

    Another option is to create a function and call that function everytime you need to select clob column.

    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;
    

    and call that function as;

    SELECT tocharvalue, clob_to_char_func(tocharvalue, 1, 9999)
    FROM (SELECT clob_column AS tocharvalue FROM table_name);
    
    0 讨论(0)
提交回复
热议问题