Dear Experts,
Pls help me to recover the following error:
Error Description:
-----------------
Warning: oci_execute() [function.oci-execute]: ORA-06550: line 1, column 8: PLS-00103: Encountered the symbol
"" when expecting one of the following: begin function package pragma procedure subtype type use <an
identifier> <a double-quoted delimited-identifier> form current cursor in
E:\WebServer\Apache2\htdoc
s\test_bfi
le_select.
php on line 48
1: /
Database Scripts
----------------
CREATE TABLE MYLOBS
(
ID NUMBER,
MYLOB CLOB,
MYBFILE BFILE
)
CREATE OR REPLACE DIRECTORY
IMAGES_DIR AS
'E:\WebServer\Apache2\htdo
cs\test_im
ages';
GRANT READ ON DIRECTORY IMAGES_DIR TO SCOTT;
bfile_insert.php
----------------
<?php
$conn = oci_connect('scott', 'tiger', '//localhost/orcl');
// Build an INSERT for the BFILE names
$sql = "INSERT INTO
mylobs
(
id,
mybfile
)
VALUES
(
mylobs_id_seq.NEXTVAL,
/*
Pass the file name using the Oracle directory reference
I created called IMAGES_DIR
*/
BFILENAME('IMAGES_DIR',:fi
lename)
)";
$stmt = oci_parse($conn, $sql);
// Open the directory
$dir = 'E:\\Web\\WebServer\\Apach
e2\\htdocs
\\login5\\
test_image
s';
$dh = opendir($dir)
or die("Unable to open $dir");
// Loop through the contents of the directory
while (false !== ( $entry = readdir($dh) ) ) {
// Match only files with the extension .jpg, .gif or .png
if ( is_file($dir.'/'.$entry) && preg_match('/\.(jpg|gif|pn
g)$/',$ent
ry) ) {
// Bind the filename of the statement
oci_bind_by_name($stmt, ":filename", $entry);
// Execute the statement
if ( oci_execute($stmt) ) {
print "$entry added\n";
}
}
}
oci_close($conn);
?>
bfile_select.php
----------------
<?php
$conn = oci_connect('scott', 'tiger', '//localhost/orcl');
$sql = "SELECT
id
FROM
mylobs
WHERE
-- Select only BFILES which are not null
mybfile IS NOT NULL";
$stmt1 = oci_parse($conn, $sql);
oci_execute($stmt1)
or die ("Unable to execute query\n");
$sql = "DECLARE
locator BFILE;
diralias VARCHAR2(30);
filename VARCHAR2(30);
BEGIN
SELECT
mybfile INTO locator
FROM
mylobs
WHERE
id = :id;
-- Get the filename from the BFILE
DBMS_LOB.FILEGETNAME(locat
or, diralias, filename);
-- Assign OUT params to bind parameters
:diralias:=diralias;
:filename:=filename;
END;";
$stmt2 = oci_parse($conn, $sql);
while ( $row = oci_fetch_assoc ($stmt1) ) {
oci_bind_by_name($stmt2, ":id", $row['ID']);
oci_bind_by_name ($stmt2, ":diralias", $diralias,30);
oci_bind_by_name ($stmt2, ":filename", $filename,30);
oci_execute($stmt2);
print "{$row['ID']}: $diralias/$filename\n";
}
oci_close($conn);
?>
-------------------
This code is from
http://www.oracle.com/technology/pub/articles/oracle_php_cookbook/fuecks_lobs.htmlPls help,
Regards,
Raju
Start Free Trial