Этот баннер — требование Роскомнадзора для исполнения 152 ФЗ.
«На сайте осуществляется обработка файлов cookie, необходимых для работы сайта, а также для анализа использования сайта и улучшения предоставляемых сервисов с использованием метрической программы Яндекс.Метрика. Продолжая использовать сайт, вы даёте согласие с использованием данных технологий».
Политика конфиденциальности
|
|
|
Загрузка BLOB-ов
|
|||
|---|---|---|---|
|
#18+
Есть идея грузить BLOB-поля из делфи(ДОА) в Оракл так Код: plaintext 1. 2. 3. 4. 5. 6. 7. Раньше с блобами не работал, поэтому может есть какие грабли? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 15.11.2003, 14:51 |
|
||
|
Загрузка BLOB-ов
|
|||
|---|---|---|---|
|
#18+
в документации по ДОА написано, что для работы с BLOB полями нужно использовать локаторы (лишнее выкинишь сам): var ... LOB: TLOBLocator; ... begin ... with DMForm.TempInOraQuery do begin Clear; SQL.Add('INSERT INTO '+AttachTableNameEdit.Text+' (Receive_Time, Dir_Name, Name_File, Body_File)'); SQL.Add('VALUES (:RecTime, :DirName, :Name_File, empty_blob())'); SQL.Add('RETURNING Body_File INTO :Body_File'); DeclareVariable('RecTime', otDate); DeclareVariable('Name_File', otString); DeclareVariable('Body_File', otBLOB); DeclareVariable('DirName', otString); SetVariable('DirName', TempDirInside); SetVariable('RecTime', RecTime); SetVariable('Name_File', searchRecFile.Name); LOB := TLOBLocator.Create(DMForm.OraSession, otBLOB); SetComplexVariable('Body_File', LOB); Execute; LOB.LoadFromFile(TempDir+'\'+SearchRecFile.Name); LOB.Free; end; ... end; ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 16.11.2003, 16:42 |
|
||
|
Загрузка BLOB-ов
|
|||
|---|---|---|---|
|
#18+
"SQL.Add('INSERT INTO '+AttachTableNameEdit.Text+' (Receive_Time, Dir_Name, Name_File, Body_File)'); SQL.Add('VALUES (:RecTime, :DirName, :Name_File, empty_blob())'); SQL.Add('RETURNING Body_File INTO :Body_File'); " Вот здесь что происходит? Можно чуть объяснить. Я так понимаю, что создаётся строка сначала с пустым блобом. А потом туда каким-то макаром (скорее всего в этих строках: SetComplexVariable('Body_File', LOB); LOB.LoadFromFile(TempDir+'\'+SearchRecFile.Name); ) записывается сам файл. Вопрос 1-ый: что даёт RETURNING Body_File INTO :Body_File') в insert'e ? Вопрос 2-ой: как вообще это работает (где тут update??) Вопрос 3-ий: как без инсёрта сие реализовать? Т.е. у меня например в таблица tab (id integer, b blob).. как мне сделать что-то типа update tab set b=bbbb (данные) where id=121 ? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.11.2003, 15:28 |
|
||
|
Загрузка BLOB-ов
|
|||
|---|---|---|---|
|
#18+
вот что написано в документации: You need to insert new LOB data into a table in two situations: 1. You are inserting a new record. 2. You are updating a record where the old value of the LOB column is null. In this case, the record does not contain a LOB Locator that you can use to write data to. If you are not using a temporary LOB, you must first insert/update an empty LOB Locator into the record. To do so, you can use the SQL function empty_blob() or empty_clob() in an insert or update statement. On the server, the LOB Locator will be initialized. The initialized LOB Locator can then be returned to the client in a variable by using the new Oracle8 returning clause. After this, you can start writing data to the LOB column. Note that you must use SetComplexVariable to set a LOB variable. The following is an example of an insert: var LOB: TLOBLocator; Buffer: array[0..99] of Byte; begin // insert into lobtable (id, lobcolumn) values (:id, empty_blob()) // returning lobcolumn into :lobcolumn with LOBQuery do begin SetVariable('id', 1); // Create a new BLOB (initially Null) LOB := TLOBLocator.Create(Session, otBLOB); // Assign it to the returning variable SetComplexVariable('lobcolumn', LOB); Execute; // After the insert, use the LOB Locator to write the data LOB.Write(Buffer, 100); LOB.Free; end; end; If you are using temporary LOB's, you can write the LOB data before executing the query, and directly use this LOB data for an insert or update without a returning clause: var LOB: TLOBLocator; Buffer: array[0..99] of Byte; begin // insert into lobtable (id, lobcolumn) values (:id, :lobcolumn) with LOBQuery do begin SetVariable('id', 1); // Create a new temporary BLOB and write the data LOB := TLOBLocator.CreateTemporary(Session, otBLOB, True); LOB.Write(Buffer, 100); // Assign it to the returning variable SetComplexVariable('lobcolumn', LOB); // Insert it Execute; LOB.Free; end; end; ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.11.2003, 16:09 |
|
||
|
Загрузка BLOB-ов
|
|||
|---|---|---|---|
|
#18+
Подскажите пожалуйста: делаю по всем хелпам и советам, как бы не пытался занести значение в CLOB поле (пишу на С++ Builder) LOB->AsString = S; LOB->Write(S.c_str(), S.Length()); ..................................... Результат один - "TLOBLocator : Invalid handle" ЧТО ДЕЛАТЬ??? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 24.11.2003, 18:57 |
|
||
|
|

start [/forum/topic.php?fid=58&msg=32325400&tid=2115782]: |
0ms |
get settings: |
8ms |
get forum list: |
13ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
59ms |
get topic data: |
10ms |
get forum data: |
2ms |
get page messages: |
37ms |
get tp. blocked users: |
1ms |
| others: | 251ms |
| total: | 387ms |

| 0 / 0 |
