Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> PROBLEM WITH LONG RAW FIELDS

PROBLEM WITH LONG RAW FIELDS

From: Enrico Mambrucchi <emambrucchi_at_seldat.it>
Date: Thu, 23 Mar 2000 08:48:50 +0100
Message-ID: <8bciaf$h31$1@serv1.iunet.it>


Well, I use these functions below to read and write long raw columns to/from RTF files.
Everything seems to work out but sometime it could appear some invalid character in the document. It seems to be without any sense...not always, and especially with long documents...What can I do to adoid this?? By the way, I use VB6.0 SP3, ORACLE 8.1.5, and ADO 2.5 to connect to ORACLE by the MICROSOFT ODBC DRIVER FOR ORACLE.

Thanks
Enrico Mambrucchi
emambrucchi_at_seldat.it
--
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

    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

End Function Received on Thu Mar 23 2000 - 01:48:50 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US