sql >> データベース >  >> RDS >> Oracle

OracleDBから画像を取得する

    lretorno.Load(...)がデータを読み取るために何をしているのかわかりませんが、selectステートメントを使用したこのsudoコードサンプルが役立つかもしれません...私は常にblobを具体的に取得して読み取る必要がありました過去のバイトを取得します。

    LONG RAWを取得する例 DataType

    var imgCmd = new OracleCommand("SELECT photo FROM photos WHERE photo_id = 1", _con);
    imgCmd.InitialLONGFetchSize = -1; // Retrieve the entire image during select instead of possible two round trips to DB
    var reader = imgCmd.ExecuteReader();
    if (reader.Read()) {
        // Fetch the LONG RAW
        OracleBinary imgBinary = reader.GetOracleBinary(0);
        // Get the bytes from the binary obj
        byte[] imgBytes = imgBinary.IsNull ? null : imgBinary.Value;
    }
    reader.Close();
    

    BLOBを取得する例 DataType

    var imgCmd = new OracleCommand("SELECT photo FROM photos WHERE photo_id = 1", _con);
    var reader = imgCmd.ExecuteReader();
    if (reader.Read()) {
        // Fetch the blob
        OracleBlob imgBlob = reader.GetOracleBlob(0);
        // Create byte array to read the blob into
        byte[] imgBytes = new byte[imgBlob.Length];
        // Read the blob into the byte array
        imgBlob.Read(imgBytes, 0, imgBlob.Length);
    }
    reader.Close();
    



    1. PHPで実行されるMySQLファイル内でPHPセッション変数を使用しますか?

    2. Oracle番号の桁数を確認する方法

    3. 行が更新または挿入されたかどうかを検出します

    4. SQLおよび関係代数の列の順序に関係なく、タプルの各ペアを1回だけリストする方法は?