Sommaire
Oracle 8
ociDefineByName
ociBindByName
ociLogon
ociPLogon
ociNLogon
ociLogOff
ociexecute
ociCommit
ociRollback
ociNewDescriptor
ociRowCount
ociNumCols
ociResult
ociFetch
ociFetchInto
ociFetchStatement
ociColumnIsNULL
ociColumnName
ociColumnSize
ociColumnType
ociServerVersion
ociStatementType
ociNewCursor
ociFreeStatement
ociFreeCursor
ociFreeDesc
ociparse
ociError
ociinternaldebug
OCICancel
ocisetprefetch
OCIWriteLobToFile
OCISaveLobFile
OCISaveLob
OCILoadLob
OCIColumnScale
OCIColumnPrecision
OCIColumnTypeRaw
OCINewCollection
OCIFreeCollection
OCICollAssign
OCICollAssignElem
OCICollGetElem
OCICollMax
OCICollSize
OCICollTrim
|
6.68.10 ociNewDescriptor[ Exemples avec ociNewDescriptor ] Description
resource ocinewdescriptor(resource connection ,[int type ])
ocinewdescriptor alloue l'espace
nécessaire pour stocker un descripteur, ou un pointeur
de LOB. Les valeurs acceptées pour type sont
oci_D_FILE, oci_D_LOB et oci_D_ROWID.
ocinewdescriptor |
<?php /* Ce script est fait pour être appelé dans un formulaire HTML * Il attends les variables $user, $password, $table, $where, et $commitsize * Le script efface alors les lignes sélectionnées avec ROWID et valide * l'effacement après chaque groupe de $commitsize lignes. * (Utilisez avec prudence, car il n'y a pas d'annulation possible). */ $conn = ociLogon($user, $password); $stmt = ociparse($conn,"select rowid from $table $where"); $rowid = ociNewDescriptor($conn,oci_D_ROWID); ociDefineByName($stmt,"ROWID",&$rowid); ociexecute($stmt); while ( ociFetch($stmt) ) { $nrows = ociRowCount($stmt); $delete = ociparse($conn,"delete from $table where ROWID = :rid"); ociBindByName($delete,":rid",&$rowid,-1,oci_B_ROWID); ociexecute($delete); print "$nrows\n"; if ( ($nrows % $commitsize) == 0 ) { ociCommit($conn); } } $nrows = ociRowCount($stmt); print "$nrows effacées...\n"; ociFreeStatement($stmt); ociLogoff($conn); ?>
|
<?php /* Ce script est fait pour être appelé depuis un formulaire HTML. * Il attends les variables $user, $password, $table, $where, et $commitsize, * données par le formulaire. Le script efface * les lignes sélectionnées avec ROWID est valide les transactions * à chaque jeu de $commitsize lignes. (Attention : il n'y plus d'annulation) */ if(!isset($lob_upload) || $lob_upload == 'none'){ ?> <form action="upload.php3" method="post" enctype="multipart/form-data"> Upload file: <input type="file" name="lob_upload"><br> <input type="submit" value="Upload"> - <input type="reset"> </form> <?php } else { // $lob_upload contains the temporary filename of the uploaded file $conn = ociLogon($user, $password); $lob = ociNewDescriptor($conn, oci_D_LOB); $stmt = ociparse($conn,"insert into $table (id, the_blob) values(my_seq.NEXTVAL, EMPTY_BLOB()) returning the_blob into :the_blob"); ociBindByName($stmt, ':the_blob', &$lob, -1, oci_B_BLOB); ociexecute($stmt, oci_DEFAULT); if($lob->savefile($lob_upload)){ ociCommit($conn); echo "Blob sauvé!\n"; }else{ echo "Impossible de sauver le Blob\n"; } ociFreeDescriptor($lob); ociFreeStatement($stmt); ociLogoff($conn); } ?>
Exemple avec ocinewdescriptor |
<?php /* Appel d'une procédure PL/SQL stockée qui prend un clobs * en entrée (PHP 4 >= 4.0.6). * Exemple de signateure de procédure stockée PL/SQL : * * PROCEDURE save_data * Nom de l'argument Type In/Out Default? * ------------------------------ ----------------------- ------ -------- * KEY NUMBER(38) IN * DATA CLOB IN * */ $conn = OCILogon($user, $password); $stmt = OCIParse($conn, "begin save_data(:key, :data); end;"); $clob = OCINewDescriptor($conn, OCI_D_LOB); OCIBindByName($stmt, ':key', $key); OCIBindByName($stmt, ':data', $clob, -1, OCI_B_CLOB); $clob->WriteTemporary($data); OCIExecute($stmt, OCI_DEFAULT); OCICommit($conn); $clob->close(); $clob->free(); OCIFreeStatement($stmt); ?>
|
|