Why Do I get OutOfRange Exception in GetOrdinal Function of this CLOB field?

后端 未结 2 739
南方客
南方客 2020-12-21 15:39

This is the sample of my code. The field FUNCTION_SCRIPT is a CLOB field (the only CLOB field) in my table IS_FUNCTION

public void ReadFunction(string FName         


        
2条回答
  •  囚心锁ツ
    2020-12-21 16:28

    Try this

    command.CommandText = "SELECT TO_CLOB(TO_NCLOB(FUNCTION_SCRIPT)) AS FUNCTION_SCRIPT FROM IS_FUNCTION where FNAME=:fName ";
    

    Right now your query does not have a name because you've applied a function to the name so you need to ALIAS it to give it a name e.g AS FUNCTION_SCRIPT

    UPDATE

    OracleDataReader odr = command.ExecuteReader();
    if(odr.HasRows)
    {
      int temp = odr.GetOrdinal("FUNCTION_SCRIPT");
      OracleLob myLob = odr.GetOracleLob(temp);
      fContent = (String)myLob.Value;
    }
    else
       throw new Exception("No rows returned from database");
    

提交回复
热议问题