Skip to content

Instantly share code, notes, and snippets.

@kllaudyo
Created March 9, 2020 19:21
Show Gist options
  • Save kllaudyo/d51f06f593dca8cf53036f5f98eda439 to your computer and use it in GitHub Desktop.
Save kllaudyo/d51f06f593dca8cf53036f5f98eda439 to your computer and use it in GitHub Desktop.
Clob
<!--#include file="../util/adovbs.inc"-->
<!--#include file="../util/un_util_objetos.asp"-->
<%
sFileName = "SAP_99999.txt"
Set oFileSystem = Server.CreateObject("Scripting.FileSystemObject")
Set oFile = oFileSystem.OpenTextFile(Server.MapPath(sFileName), 1, True)
sMailMsg = ""
Do Until oFile.AtEndOfStream
sMailMsg = sMailMsg & oFile.ReadLine
Loop
Set oFile = Nothing
Set oFileSystem = Nothing
iLength = Len(sMailMsg)
iId = ""
For i = 0 To Fix(iLength/4000)
sBlock = Mid(sMailMsg, (i*4000)+1, 4000)
If i = 0 Then
Set oRs = CN_Banco.Execute("SELECT SQ_EMAIL_SAP.NEXTVAL FROM DUAL")
iId = oRs(0)
Set oRs = Nothing
sSQL = ""
sSQL = sSQL & "INSERT INTO EMAIL_SAP "
sSQL = sSQL & "(TE_CORPO, ID_EMAIL_SAP, NM_DE, TE_ASSUNTO, DT_EMAIL) "
sSQL = sSQL & "VALUES "
sSQL = sSQL & "(?, ?, 'CLAUDIO@CLAUDIO.COM', 'TESTE', TO_DATE('09/03/2020','DD/MM/YYYY')) "
Else
sSQL = ""
sSQL = sSQL & "UPDATE EMAIL_SAP "
sSQL = sSQL & "SET TE_CORPO = TE_CORPO || ? "
sSQL = sSQL & "WHERE ID_EMAIL_SAP = ? "
End If
Set oCmd = Server.CreateObject("ADODB.Command")
oCmd.ActiveConnection = CN_Banco
oCmd.CommandType = adCmdText
oCmd.CommandText = sSQL
oCmd.Parameters.Append oCmd.createParameter("@Corpo", adLongVarChar, adParamInput, 4000, sBlock)
oCmd.Parameters.Append oCmd.createParameter("@Id", adBigInt, adParamInput, , iId)
oCmd.Execute
Set oCmd = Nothing
Next
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment