请问,如何将long或long raw类型字段的内容复制到另一张表中?
数据库:
 Oracle 8.0.5
 Oracle 9i
说明:
 因为要与自动转换程序接口,因此绝对不能采用前端处理或手工处理的方式,只能使用sql语句或存储过程。
 谢谢大家,同时预祝大家国庆节快乐。

解决方案 »

  1.   

    long--->to_lob()
    long raw---->utl_raw
      

  2.   

    我试了试:utl_raw.length和utl_raw.substr,错误提示为:
    ORA-06550: line 4, column 39:
    PL/SQL: ORA-00997: illegal use of LONG datatype
    ORA-06550: line 4, column 2:
    PL/SQL: SQL Statement ignored不知道utl_raw内函数能否操作Long Raw型数据,怎么操作?
    还忘大家指教。
      

  3.   

    查一下utl_row包的使用方式
    我这里没装联机帮助
      

  4.   

    Summary of UTL_RAW Subprograms
    Table 98-1 UTL_RAW Subprograms  
    Subprogram Description 
    CAST_FROM_BINARY_INTEGER Function
     Returns the binary representation of a BINARY_INTEGER (in RAW).
     
    CAST_FROM_NUMBER Function
     Returns the binary representation of a NUMBER (in RAW).
     
    CAST_TO_BINARY_INTEGER Function
     Casts the binary representation of a BINARY_INTEGER (in RAW) into a BINARY_INTEGER
     
    CAST_TO_NUMBER Function
     Casts the binary representation of a NUMBER (in RAW) into a NUMBER. If include_length is TRUE, the first byte of r encodes the number of bytes in r (
     
    CAST_TO_RAW Function
     Converts a VARCHAR2 represented using n data bytes into a RAW with n data bytes.
     
    CAST_TO_VARCHAR2 Function
     Converts a RAW represented using n data bytes into VARCHAR2 with n data bytes.
     
    CONCAT Function
     Concatenates up to 12 RAWs into a single RAW.
     
    LENGTH Function
     Returns the length in bytes of a RAW r.
     
    SUBSTR Function
     Returns len bytes, starting at pos from RAW r.
     
    TRANSLATE Function
     Translates the bytes in the input RAW r according to the bytes in the translation RAWs from_set and to_set.
     
    TRANSLITERATE Function
     Converts the bytes in the input RAW r according to the bytes in the transliteration RAWs from_set and to_set.
     
    OVERLAY Function
     Overlays the specified portion of target RAW with overlay RAW, starting from byte position pos of target and proceding for len bytes.
     
    COPIES Function
     Returns n copies of r concatenated together.
     
    XRANGE Function
     Returns a RAW containing all valid 1-byte encodings in succession, beginning with the value start_byte and ending with the value end_byte.
     
    REVERSE Function
     Reverses a byte sequence in RAW r from end to end.
     
    COMPARE Function
     Compares RAW r1 against RAW r2.
     
    CONVERT Function
     Converts RAW r from character set from_charset to character set to_charset and returns the resulting RAW.
     
    BIT_AND Function
     Performs bitwise logical "and" of the values in RAW r1 with RAW r2 and returns the "anded" result RAW.
     
    BIT_OR Function
     Performs bitwise logical "or" of the values in RAW r1 with RAW r2 and returns the "or'd" result RAW.
     
    BIT_XOR Function
     Performs bitwise logical "exclusive or" of the values in RAW r1 with RAW r2 and returns the "xor'd" result RAW.
     
    BIT_COMPLEMENT Function
     Performs bitwise logical "complement" of the values in RAW r and returns the "complement'ed" result RAW.
     
      

  5.   

    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/u_raw2.htm#1001736
      

  6.   

    http://gigabase.idi.ntnu.no/oradoc/appdev.901/a89852/utl_raw.htm#998101
      

  7.   

    http://gigabase.idi.ntnu.no/oradoc/appdev.901/a89852/utl_raw.htm#998101
      

  8.   

    utl_raw.length 对 LONG不行
      用INSERT INTO TABLE_NAME1 SELECT * FROM TABLE_NAME。
      

  9.   

    首先谢谢各位大哥了。小弟太笨还是搞不定,还望祥加指点。 采用:Insert into .. select .. 形式也不行,错误如下: ORA-00997: illegal use of LONG datatype我相信Oracle一定可以做到,但我就是不知道怎么做。楼上各位给在下介绍了Utl_raw包,我还是不知道怎么访问Long raw类型字段,不管小弟怎么试,总提示:
      illegal use of LONG datatype 错误。不管用什么办法,只要不通过前台应用程序,实现将Long raw类型字段内数据从一个表到另一个表的移植就可以,小弟都快急风了。
    谢谢大家。
      

  10.   

    你可以这样复制long raw记录
    1.首先创建一个表A,如:
    create table A(zxtmc varchar2(50),mknr blob)2.表XT_MKDA有两个字段:zxtmc varchar2(50),mknr long raw
    把xt_mkda的数据插入ttt中:
    insert into ttt
    select zxtmc,to_lob(mknr) from XT_MKDA3.创建表B:
    create table B(zxtmc varchar2(50),mknr long raw)4.复制表A 的记录到表B:
    insert into B
    select zxtmc,mknr from A5.查看select * from B
    表B就是你要的结果long raw类型字段的内容复制到另一张表中
      

  11.   

    更正:
    2.表XT_MKDA有两个字段:zxtmc varchar2(50),mknr long raw
    把xt_mkda的数据插入ttt中:
    insert into ttt
    select zxtmc,to_lob(mknr) from XT_MKDA应为:
    2.表XT_MKDA有两个字段:zxtmc varchar2(50),mknr long raw
    把xt_mkda的数据插入A中:
    insert into A
    select zxtmc,to_lob(mknr) from XT_MKDA
      

  12.   

    zhangshunshi(宇轩) 
    ------------------------------
    你可以这样复制long raw记录
    1.首先创建一个表A,如:
    create table A(zxtmc varchar2(50),mknr blob)2.表XT_MKDA有两个字段:zxtmc varchar2(50),mknr long raw
    把xt_mkda的数据插入A中:
    insert into A
    select zxtmc,to_lob(mknr) from XT_MKDA3.创建表B:
    create table B(zxtmc varchar2(50),mknr long raw)4.复制表A 的记录到表B:
    insert into B
    select zxtmc,mknr from A5.查看select * from B
    表B就是你要的结果long raw类型字段的内容复制到另一张表中
    ----------------------------------------
    问题在于PL/SQL不支持你这样的使用,我在SQL PLUS下面是直接可以执行的,但PL/SQL总报错,说类型不匹配