Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Inserting a Null value in BLOB field in Oracle

Inserting a Null value in BLOB field in Oracle

Scheduled Pinned Locked Moved C#
csharpdatabaseoraclehelpquestion
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kalyanPaladugu
    wrote on last edited by
    #1

    I have a Blob field in a table in oracle database. Some times i need to put null values into this field This is what iam doing in my C# Code byte[] blobTest = new byte[0]; string insert = "INSERT INTO exampel VALUES(:test)"; OracleParameter test = new OracleParameter(); test.OracleType = OracleType.Blob; test.ParameterName = "test"; test.Value = blobTest; con.Open(); cmd = new OracleCommand(insert, con); cmd.Parameters.Add(test); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); Its throwing up an error ORA-01459 invalid length for variable if i change byte[] blobTest = new byte[1]; in the above code its working. Basically how do i pass in a null value for a blob field in oracle database. Thanks kal

    M 1 Reply Last reply
    0
    • K kalyanPaladugu

      I have a Blob field in a table in oracle database. Some times i need to put null values into this field This is what iam doing in my C# Code byte[] blobTest = new byte[0]; string insert = "INSERT INTO exampel VALUES(:test)"; OracleParameter test = new OracleParameter(); test.OracleType = OracleType.Blob; test.ParameterName = "test"; test.Value = blobTest; con.Open(); cmd = new OracleCommand(insert, con); cmd.Parameters.Add(test); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); Its throwing up an error ORA-01459 invalid length for variable if i change byte[] blobTest = new byte[1]; in the above code its working. Basically how do i pass in a null value for a blob field in oracle database. Thanks kal

      M Offline
      M Offline
      mikone
      wrote on last edited by
      #2

      Could you please replace these lines below test.OracleType = OracleType.Blob; test.ParameterName = "test"; test.Value = blobTest; with these lines test.OracleType = OracleType.Blob; test.IsNullable = true; test.ParameterName = "test"; test.Value = null; i haven't done anything in oracle yet but it sounds related to your problem ;D and instead of setting the value to a bytearray consisting of one byte, you should try to put a c# null value on it because the developers probably implemented a c# null to oracle null conversion ;D

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups