writing a blob

From: Erin Walter <emwalter_at_engin.umich.edu>
Date: 17 Oct 2001 10:09:55 -0700
Message-ID: <f73db37a.0110170909.2e1a0ce6_at_posting.google.com>


I am having a bunch of problems writing a blob and getting the correct results back. I am attempting to write a long string of zeros and ones representing a binary string. I am reading like this, from Java code:

   public static void TheFunction(java.sql.Blob oMyBlob)    {           

	  long nblobLength  =  oMyBlob.length();//the length of the blob
      	  System.out.println("the blob length is "+ nblobLength); 
	  blobByteArray =  oMyBlob.getBytes(1, (int)nblobLength);//should
have all of blob in a byte array now.
          System.out.println("after creation of the blobByte array,
the first byte is: " + ((int)blobByteArray[1]));

   }

an example of the string that I wish to insert into the blob is: insert into The_Table values(

00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000001100001111111111111111111111111111111111111111111111111111111111111
etc....);

Here are the ways that I have attempted to put it in, via the sqlplus command line, thus far:

  1. utl_raw.cast_to_raw('0000....000')); result -- It printed out 48 as the result of a byte that was all 0's
  2. '0000...0000' (a small amount of it) result -- It worked!! but, need about 9 times as much
  3. '0000...0000' (All of it) result -- '000000000000000000000000000000000000000000000000000000000000 * ERROR at line 2: ORA-01465: invalid hex number
  4. 000000.....00000 (all of it) result -- 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 * ERROR at line 3: RA-00917: missing comma
  5. utl_raw.cast_to_VARCHAR2('00000....0000') result -- utl_raw.CAST_TO_VARCHAR2('000000000000000000000000000000000000000000000000000000000000 * ERROR at line 2: ORA-06502: PL/SQL: numeric or value error: hex to raw conversion error ORA-06512: at line 1
  6. utl_raw.concat(00000000000000000000000000000000000000000000000, 00000000000000000000000000000000000000000000000000000000000000000000, 00000001000000000000000000000000000000000011000011111111111111111111, 11111111111111111111111111111111111111111111111111111111111111, 111111111111111111111111111111111111111111111111111111111111111111111, 11111111111111111111111111111111111111111111111111111111111111111111111, 11111111111111111111111111111111111111111111111111111111111111111111, 11111111111111111111111111111111111111111111111111111111111111111111111, 111111111111111111111111111111111111111111111111111111111111111111111111, 111111111111111111111111111111111111111111111111111111111111111111111));
      ERROR at line 2:
      ORA-06553: PLS-306: wrong number or types of arguments in call
to 'CONCAT'
      
      
   7) utl_raw.concat('0000000000000000000000000000000000000000000000000000000000',

'000000000000000000000000000000000000000000000000000000000000000000000',
'0000000100000000000000000000000000000000001100001111111111111111111111',
'1111111111111111111111111111111111111111111111111111111111111111111111',
'1111111111111111111111111111111111111111111111111111111111111111111111',
'1111111111111111111111111111111111111111111111111111111111111111111111',
'1111111111111111111111111111111111111111111111111111111111111111111111',
'1111111111111111111111111111111111111111111111111111111111111111111111',
'1111111111111111111111111111111111111111111111111111111111111111111111',
'11111111111111111111111111111111111111111111111111111111111111111111111111',
'11111111111111111111111111111111111111111111111111111111111111111111111'));

    result -- It worked!!! But, it says the length is only 500...It is more than that, I have shortened it a little here,....it does not seem to want to take the whole thing.

any ideas??? any help would be greatly appreciated. I really don't know anything about blobs...it is my first time ever working with them.

Thanks,

        Erin Walter Received on Wed Oct 17 2001 - 19:09:55 CEST

Original text of this message