Re: Adding blobs to Oracle
| From: | thies at digicol dot de | Date: | Thu, 22 Jun 2000 17:44:15 +0000 |
| Subject: | Re: Adding blobs to Oracle | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-581@lists.php.net to get a copy of this message | ||
On Thu, Jun 22, 2000 at 06:06:31PM +0100, David Newcomb wrote:
>
> Hi All,
>
> Having a bit of trouble with adding BLOBs to Oracle 8, and was wandering if
> anyone has managed to do it.
> I have read the example in function.ocinewdescriptor.html to no avail.
>
> Given a table
> create table upload (
> id number(10),
> the_blob blob );
>
> and running the PHP program:
>
> <?php
> /* This script demonstrates file upload to LOB columns
> * The formfield used for this example looks like this
> * <form action="upload.php3" method="post"
> enctype="multipart/form-data">
> * <input type="file" name="lob_upload">
> * ...
> */
> if(!isset($lob_upload) || $lob_upload == 'none'){
> ?>
>
> <form action="example.php" 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("webdb", "webdb");
> $lob = OCINewDescriptor($conn, OCI_D_LOB);
> $stmt = OCIParse($conn,"insert into upload (id, the_blob)
> values('1', EMPTY_BLOB()) returning the_blob into
> :the_blob");
>
> OCIBindByName($stmt, ':the_blob', &$lob, -1, OCI_B_BLOB);
change:
> OCIExecute($stmt);
to:
OCIExecute($stmt,OCI_DEFAULT);
>
> if($lob->savefile($lob_upload))
> {
> OCICommit($conn);
> echo "Blob successfully uploaded<br>\n";
> }
> else
> {
> echo "Couldn't upload Blob<br>\n";
> }
>
> $lob->free();
> OCIFreeStatement($stmt);
add:
OCICommit($conn);
> OCILogoff($conn);
> }
>
> ?>
should do the trick
tc
>
> It says:
>
> Warning: OCILobWrite: ORA-22990: LOB locators cannot span transactions in
> /home/httpd/html/djn/vnvi/example.php on line 30
> Couldn't upload Blob
>
> Any ideas anyone? I'm stumped.
>
> David.
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!"
Digital Collections Phone +49 40 235350 Fax +49 40 23535180
Hammerbrookstr. 93 20097 Hamburg / Germany