【问题标题】:Insert contents of a text file into the Oracle CLOB将文本文件的内容插入 Oracle CLOB
【发布时间】:2015-12-07 18:21:09
【问题描述】:

我正在尝试将 file.txt 的整个文本内容插入 CLOB 列!

Connection^ DB = gcnew Connection();
OracleConnection^ Ocnn=DB->getOracleConnectionObject();
int number = 0;

try {
    // here >>
    OracleCommand^ c = gcnew OracleCommand("INSERT INTO PANDA.PAGE(SITE_ID, URL, SOURCE) VALUES('40', 'www.site.com', Read_Whole_File('C://Users/farmehr/Desktop/', 'file.txt'))", Ocnn);
    number = c->ExecuteNonQuery();

}
catch (Exception^ eOra) {
    Console::WriteLine(eOra->Message + "Exception Caught");
    throw eOra;
}

我想知道有没有办法直接将文件插入数据库? (代码中类似 Read_Whole_File() 的函数)

【问题讨论】:

    标签: c++ oracle visual-studio-2015 clob


    【解决方案1】:

    为了能够首先将文件插入到 clob 中,我必须在 SQLPLUS 中创建一个过程! SOURCE 是我的 clob 文件,TEMP_CLOB 是预定义的目录。

    接下来在我的代码中我必须运行这个过程:

    使用代码:

    结果:

    -请记住,要创建和运行程序,您必须登录 AS SYSDBA。(如果您使用 C 或 .NET,请将 oracleClient.dll 更改为 OracleManagedAcess.dll)

    【讨论】:

      猜你喜欢
      • 2021-12-29
      • 1970-01-01
      • 2018-10-29
      • 1970-01-01
      • 2017-11-06
      • 1970-01-01
      • 1970-01-01
      • 2010-11-28
      • 1970-01-01
      相关资源
      最近更新 更多