Insert Oracle records with attachments

Hi everybody,

I’ve got a problem with the new appication I’m working on. It receives mail and fo each one received the application has to create a record in an Oracle table, including a maximun of 5 attachments contained in the mail.

The code below is the one that makes the main part. When executing the following sentence

Call lcora.Insert( fldlistora )

it returns the error 12802.

I tried to solve it by using the flag

LCFIELDF_TRUNC_PREC

in field lists but it didn’t work

Any sugestions, please?

Thanks in advance

Dim ses As New NotesSession

Dim bd As NotesDatabase

Dim colec As NotesDocumentCollection

Dim doc As NotesDocument

Dim rtitem As NotesRichTextItem

Dim dtFecha As New NotesDateTime( “01/01/2000” )

Dim dtFecha2 As NotesDateTime

Dim consulta As String

Dim intCont As Long

Dim strCadenaInsert As String

Dim conectado As Variant

Dim anyo As Integer

Dim mes As Integer

Dim dia As Integer

'Definición de conectores

Dim lcora As LCConnection

Dim lcfile As LCConnection

'Definición de las listas de campos de los conectores

Dim fldlistora As LCFieldList

Dim fldlistfile As New LCFieldList( 1, LCFIELDF_TRUNC_PREC )

'Campos de la tabla Oracle

Dim fldid As LCField

Dim fldasunto As LCField

Dim fldcreador As LCField

Dim fldsolicitante As LCField

Dim fldfecha As LCField

Dim fldcuerpo As LCField

Dim fldadjunto1 As LCField

Dim fldadjunto2 As LCField

Dim strTexto As New LCStream

Dim datFecha As LCDatetime

On Error Goto TratarError

ObtenerParametros

conectado = False

'Se crean las conexiones

Set lcora = New LCConnection( “oracle8” )

Set lcfile = New LCConnection( “file” )

'Se crean los campo para las columans de la tabla Oracle

Set fldid = New LCField( LCTYPE_TEXT )

Set fldasunto = New LCField( LCTYPE_TEXT )

Set fldcreador = New LCField( LCTYPE_TEXT )

Set fldsolicitante = New LCField( LCTYPE_TEXT )

Set fldfecha = New LCField( LCTYPE_DATETIME )

Set fldcuerpo = New LCField( LCTYPE_TEXT )

Set fldadjunto1 = New LCField( LCTYPE_BINARY )

Set fldadjunto2 = New LCField( LCTYPE_BINARY )

'Se crea la lista de campos con los campos definidos antes

Set fldlistora = New LCFieldList( 1, LCFIELDF_TRUNC_PREC )

Call fldlistora.IncludeField( 1, fldid, “ID” )

Call fldlistora.IncludeField( 2, fldasunto, “ASUNTO” )

Call fldlistora.IncludeField( 3, fldcreador, “CREADOR” )

Call fldlistora.IncludeField( 4, fldsolicitante, “SOLICITANTE” )

Call fldlistora.IncludeField( 5, fldfecha, “FECHA” )

Call fldlistora.IncludeField( 6, fldcuerpo, “CUERPO” )

Call fldlistora.IncludeField( 7, fldadjunto1, “ADJUNTO1” )

Call fldlistora.IncludeField( 8, fldadjunto2, “ADJUNTO2” )

'Datos de la conexión al sistema de archivos

lcfile.Database = LOracle( “Ruta” )

lcfile.Binary = True

'Datos de la conexión a Oracle

lcora.MapByName = True

lcora.Server = LOracle( “Servicio” )

lcora.Userid = LOracle( “Usuario” )

lcora.Password = LOracle( “Password” )

lcora.Metadata = LOracle( “Tabla” )

'Realizar la conexión

lcfile.Connect

lcora.Connect

conectado = True

PrintON “Conectado a Oracle”

Set bd = ses.CurrentDatabase

consulta = {Form = “Memo” & !(Procesado = “1”)}

Set colec = bd.Search( consulta, dtFecha, 0 )

For intCont = 1 To colec.Count

Set doc = colec.GetNthDocument( intCont )



TratarDocumento doc



Set rtitem = doc.GetFirstItem( "Body" )



strTexto.Text = ValorCampo( doc, "ID" )

Call fldid.SetStream( 1, strTexto )

strTexto.Text = ValorCampo( doc, "ASUNTO" )

Call fldasunto.SetStream( 1, strTexto )

strTexto.Text = ValorCampo( doc, "CREADOR" )

Call fldcreador.SetStream( 1, strTexto )

strTexto.Text = ValorCampo( doc, "SOLICITANTE" )

Call fldsolicitante.SetStream( 1, strTexto )



strTexto.Text = ValorCampo( doc, "FECHA" )

Set dtFecha2 = New NotesDateTime( Cdat( strTexto.Text ) )



anyo = Year( dtFecha2.LSLocalTime )

mes = Month( dtFecha2.LSLocalTime )

dia = Day( dtFecha2.LSLocalTime )



Set datFecha = New LCDatetime( anyo, mes, dia )

Call fldfecha.SetDatetime( 1, datFecha )



strTexto.Text = Left( ValorCampo( doc, "CUERPO" ), 100 )

Call fldcuerpo.SetStream( 1, strTexto )



Call lcfile.Select( Nothing, 1, fldlistfile )

Do While lcfile.Fetch( fldlistfile )

	Set fldadjunto1 = fldlistfile.Lookup( "Contents" )

	Exit Do



Loop



Call lcora.Insert( fldlistora )



EliminarArchivos doc

Next

If conectado Then

lcfile.Disconnect

lcora.Disconnect

End If

Exit Sub

TratarError:

Select Case Err

Case 75

Resume Next

Case Else

Msgbox Cstr( Err ) & ": " & Error$( Err )



If conectado Then

	lcfile.Disconnect

	lcora.Disconnect



End If



Exit Sub

End Select