Ecrire dans une colonne LONG RAW
Date de publication : 22/12/05
Par
Stéphanie Tirtiat (Intl Tech Support) Code exemple pour écrire dans une colonne Oracle de type LONG RAW avec 4D for OCI
Produit : 4D OCI 2004.3 · Plateforme : Mac & Win
Avec 4D for OCI 2004.3, vous pouvez envoyer du contenu dans une colonne LONG RAW d'une base Oracle.
Code exemple :
C_ENTIER LONG(envhp;errhp;svchp)
C_ENTIER LONG(Define;stmthp;stmtSelecthp)
C_ENTIER(RealLength)
C_BLOB(ZeBlob)
FIXER TAILLE BLOB(ZeBlob;0)
C_ENTIER LONG(vp_Null1)
C_POINTEUR(vp_Null3)
C_HEURE($DocRef)
C_TEXTE($Path)
$DocRef:=Ouvrir document("";"";Lire chemin accès )
Si (OK=1)
$Path:=document
FERMER DOCUMENT($DocRef)
Fin de si
DOCUMENT VERS BLOB($Path;ZeBlob)
WriteLength:=Taille BLOB(ZeBlob)
C_TEXTE($UserName;$Password;$DbService;$SQLStatement)
$UserName:="xxx"
$Password:="xxx"
$DbService:="xxx"
$Status:=OCIEnvCreate (envhp;OCI_OBJECT )
$Status:=OCIHandleAlloc (envhp;errhp;OCI_HTYPE_ERROR )
$Status:=OCILogon (envhp;errhp;svchp;$UserName;$Password;$DbService)
$Status:=OCIHandleAlloc (envhp;stmthp;OCI_HTYPE_STMT )
$SQLStatement:="INSERT INTO test_LGRAW (key, lgraw) "
$SQLStatement:=$SQLStatement+"VALUES (3, EMPTY_BLOB())"
$Status:=OCIStmtPrepare (stmthp;errhp;$SQLStatement;OCI_DEFAULT )
$Status:=OCIStmtExecute (svchp;stmthp;errhp;1;0;0;0;OCI_DEFAULT )
$SQLStatement:="UPDATE test_LGRAW SET lgraw=:1 WHERE key=3"
$Status:=OCIHandleAlloc (envhp;stmtSelecthp;OCI_HTYPE_STMT )
$Status:=OCIStmtPrepare (stmtSelecthp;errhp;$SQLStatement;OCI_DEFAULT )
vp_Null1:=1
WriteLength:=Taille BLOB(ZeBlob)
$Status:=OCIBindByPos (stmtSelecthp;Define;errhp;1;->ZeBlob;SQLT_LBI ;->vp_Null1; ->WriteLength;->vp_Null3;OCI_DATA_AT_EXEC )
$status:=OCIErrorGet (errhp;1;$errornum;$errorexplain)
Si ($errornum#0)
ALERTE(Chaine($errornum)+Caractere(13)+$errorexplain)
Fin de si
$Status:=OCIStmtExecute (svchp;stmtSelecthp;errhp;1;0;0;0;OCI_DEFAULT )
$Status:=OCIHandleFree (stmtSelecthp)
$status:=OCIErrorGet (errhp;1;$errornum;$errorexplain)
Si ($errornum#0)
ALERTE(Chaine($errornum)+Caractere(13)+$errorexplain)
Fin de si
$Status:=OCIHandleFree (stmthp)
$Status:=OCILogoff (svchp;errhp)
$Status:=OCIHandleFree (errhp)
$Status:=OCICleanUp (envhp)
 
|