我手头上有个系统,在查询的时候要求对long类型字段的只值进行模糊比较,但是oracle中的long类型不直接支持模糊比较功能,有没有什么办法能够实现类似功能阿,在sql server中能够用cast将文本类型的数据强制转换成为字符串类型,但是在oracle中不知道用什么方法阿

解决方案 »

  1.   

    oracle中long类型限制较多:
    The use of LONG values is subject to some restrictions:A table can contain only one LONG column. 
    You cannot create an object type with a LONG attribute. 
    LONG columns cannot appear in WHERE clauses or in integrity constraints (except that they can appear in NULL and NOT NULL constraints). 
    LONG columns cannot be indexed. 
    A stored function cannot return a LONG value. 
    You can declare a variable or argument of a PL/SQL program unit using the LONG datatype. However, you cannot then call the program unit from SQL. 
    Within a single SQL statement, all LONG columns, updated tables, and locked tables must be located on the same database. 
    LONG and LONG RAW columns cannot be used in distributed SQL statements and cannot be replicated. 
    If a table has both LONG and LOB columns, you cannot bind more than 4000 bytes of data to both the LONG and LOB columns in the same SQL statement. However, you can bind more than 4000 bytes of data to either the LONG or the LOB column. 
    A table with LONG columns cannot be stored in a tablespace with automatic segment-space management. 
    LONG columns cannot appear in certain parts of SQL statements:GROUP BY clauses, ORDER BY clauses, or CONNECT BY clauses or with the DISTINCT operator in SELECT statements 
    The UNIQUE operator of a SELECT statement 
    The column list of a CREATE CLUSTER statement 
    The CLUSTER clause of a CREATE MATERIALIZED VIEW statement 
    SQL built-in functions, expressions, or conditions 
    SELECT lists of queries containing GROUP BY clauses 
    SELECT lists of subqueries or queries combined by the UNION, INTERSECT, or MINUS set operators 
    SELECT lists of CREATE TABLE ... AS SELECT statements 
    ALTER TABLE ... MOVE statements 
    SELECT lists in subqueries in INSERT statements 
    Triggers can use the LONG datatype in the following manner:A SQL statement within a trigger can insert data into a LONG column. 
    If data from a LONG column can be converted to a constrained datatype (such as CHAR and VARCHAR2), a LONG column can be referenced in a SQL statement within a trigger. 
    Variables in triggers cannot be declared using the LONG datatype. 
    :NEW and :OLD cannot be used with LONG columns. 
    You can use the Oracle Call Interface functions to retrieve a portion of a LONG value from the database.全文检索好像可以在这里使用,可以试试
      

  2.   

    只能把long读出来,然后判断寻找的字符是否包含其中
      

  3.   

    我是这样做的,
    建一张临时表
    create table temp_table as
    select a.xxx,to_lob(a.yyy) yyy,...
      from your_table a;
    这样就把原来long类型的yyy字段转换成log字段。。
    不然好像没什么好办法。反正建议不要用long类型,用CLOB比较好
      

  4.   

    不好意思。写错了一个地方
    log==>CLOB字段