| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> RE: long raw length
Hi
Well, the length of a long raw field should be this, if you use ORADC
component:
METHOD FieldSize
Applies To
OraField
Description
Returns the number of bytes stored in a LONG or LONG RAW field. Not
available at design time and read-only at run time.
Usage
data_size = orafield.FieldSize( )
data_size = orafield.DbFieldSize( )
Remarks
Returns the number of bytes stored in a LONG or LONG RAW field, up to a
value of around 64KB. If the field contains more than 64KB, FieldSize
returns -1 (negative one).
Oracle does not return the length of columns that are greater than 64KB, so
the only way to determine the length is to retrieve the column. To conserve
resources, columns of length greater than 64KB are not retrieved
automatically.
Data Type
Long Integer
Then I tried with these function to transfer RTF files to DB and DB to RTF
files.
It seems to work even if sometime if could happen some invalid character in
the document, especially with long ones
Public Function DBtoFile(ByVal sFileName As String, ss As ADODB.Recordset, ByVal sFieldName As String, bNew As Boolean, Modello As String) As Boolean
Dim hFile As Integer
Dim lOffset As Long
Dim vRTF As Variant
Dim FILE_PORTION As Variant
Dim LEN_BUFFER As Variant
FILE_PORTION = &H7E00&
LEN_BUFFER = 100000 ' 512
On Error GoTo errDBtoFile
If sFileName = "" Then Exit Function If sFieldName = "" Then Exit Function
' verifichiamo se abbiamo un cursore aperto, altrimenti simao nel caso di un
' nuovo record e quindi dobbiamo creare un file vuoto If (ss Is Nothing) Then
hFile = FreeFile
Open sFileName For Output As hFile
Close hFile
bNew = True
Else
If Not ss.EOF Then
If Not IsNull(ss.Fields(sFieldName).Value) Then
lOffset = 100
On Error Resume Next
ss.Update
On Error GoTo errDBtoFile
hFile = FreeFile
Open sFileName For Output As hFile
Do
vRTF = ss.Fields(sFieldName).GetChunk(FILE_PORTION)
'lOffset
If IsNull(vRTF) Then vRTF = ""
vRTF = CStr(vRTF)
If vRTF <> "" Then Print #hFile, vRTF
Loop Until vRTF = ""
Close hFile
bNew = False
Else
hFile = FreeFile
FileCopy Modello, sFileName
bNew = True
End If
Else
hFile = FreeFile
FileCopy Modello, sFileName
bNew = True
End If
DBtoFile = True
fineDBtoFile:
Exit Function
errDBtoFile:
Resume fineDBtoFile
End Function
/
Function FileToDB (Source As String, T As ADODB.Recordset, _
sField As String) As Boolean
Dim NumBlocks As Integer, SourceFile As Integer, I As Integer
Dim FileLength As Long, LeftOver As Long
Dim FileData As String
Dim RetVal As Variant
Const BlockSize = 100000
On Error GoTo Err_ReadBLOB
' Open the source file.
SourceFile = FreeFile
Open Source For Binary Access Read As SourceFile
' Get the length of the file.
FileLength = LOF(SourceFile)
If FileLength = 0 Then
ReadBLOB = 0
Exit Function
End If
' Calculate the number of blocks to read and leftover bytes.
T.Update
NumBlocks = FileLength \ BlockSize
LeftOver = FileLength Mod BlockSize
' Put first record in edit mode.
' Read the leftover data, writing it to the table.
FileData = String$(LeftOver, 32)
Get SourceFile, , FileData
T.Fields(sField).AppendChunk (FileData)
' Read the remaining blocks of data, writing them to the table.
FileData = String$(BlockSize, 32)
For I = 1 To NumBlocks
Get SourceFile, , FileData
T.Fields(sField).AppendChunk (FileData)
Next I
' Update the record and terminate function.
T.Update
Close SourceFile
ReadBLOB = True
Exit Function
Err_ReadBLOB:
ReadBLOB = False
Exit Function
I hope that this could be useful...
Bye
Enrico Mambrucchi
emambrucchi_at_seldat.it
Prakash <venkatprakash_at_hotmail.com> wrote in message
8ar8u0$us1$1_at_nnrp1.deja.com...
> Can anyone tell me how I do chunk long raw data? Also how do I know
> the length of a long raw column?
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Thu Mar 23 2000 - 01:44:21 CST
![]() |
![]() |