4D v16

Writing in a LONG RAW column

Home

 
4D v16
Writing in a LONG RAW column

Writing in a LONG RAW column  


 

 

You can use 4D for OCI to write the contents of a LONG RAW column in an Oracle database.

 C_LONGINT(envhp;errhp;svchp)
 C_LONGINT(Define;stmthp;stmtSelecthp)
 C_LONGINT(RealLength)
 C_BLOB(TheBlob)
 SET BLOB SIZE(TheBlob;0)
 C_LONGINT(vp_Null1)
 C_POINTER(vp_Null3)
 
 C_TIME($DocRef)
 C_TEXT($Path)
 $DocRef:=Open document("";"";Get Pathname)
 If(OK=1)
    $Path:=document
    CLOSE DOCUMENT($DocRef)
 End if
 DOCUMENT TO BLOB($Path;TheBlob)
 WriteLength:=BLOB size(TheBlob)
 
 C_TEXT($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:=BLOB size(TheBlob)
 $Status:=OCIBindByPos(stmtSelecthp;Define;errhp;1;->TheBlob;SQLT_LBI;->vp_Null1;
 ->WriteLength;->vp_Null3;OCI_DATA_AT_EXEC)
 $status:=OCIErrorGet(errhp;1;$errornum;$errorexplain)
 If($errornum#0)
    ALERT(String($errornum)+Char(13)+$errorexplain)
 End if
 
 $Status:=OCIStmtExecute(svchp;stmtSelecthp;errhp;1;0;0;0;OCI_DEFAULT)
 $Status:=OCIHandleFree(stmtSelecthp)
 $status:=OCIErrorGet(errhp;1;$errornum;$errorexplain)
 If($errornum#0)
    ALERT(String($errornum)+Char(13)+$errorexplain)
 End if
 
 $Status:=OCIHandleFree(stmthp)
 $Status:=OCILogoff(svchp;errhp)
 $Status:=OCIHandleFree(errhp)
 $Status:=OCIHandleFree(envhp)

 
EIGENSCHAFTEN 

Produkt: 4D
Thema: Examples of use

 
GESCHICHTE 

 
ARTIKELVERWENDUNG

4D for OCI ( 4D v16)