Passing clobs to stored procs
| From: | David Benson | Date: | Fri, 16 Feb 2001 17:40:00 +0000 |
| Subject: | Passing clobs to stored procs | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-6691@lists.php.net to get a copy of this message | ||
I'm trying to pass a clob to a stored procedure, but not having any luck.
desc php_test
PROCEDURE php_test
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
I_ID NUMBER IN
I_TEXT CLOB IN
Here's my code and the variants I tried:
<?
$Conn = OCINLogon ('xxx', 'xxx');
OCIInternalDebug (1);
$Buffer = "hello there";
$Stmt = OCIParse ($Conn, 'begin php_test (1, :buffer); end;');
$Clob = OCINewDescriptor ($Conn, OCI_D_LOB);
OCIBindByName ($Stmt, ':buffer', $Clob, -1, OCI_B_CLOB);
$Clob->save ($Buffer);
OCIExecute ($Stmt, OCI_DEFAULT);
$Stmt = OCIParse ($Conn, 'begin php_test (2, :buffer); end;');
OCIBindByName ($Stmt, ':buffer', $Buffer);
OCIExecute ($Stmt);
$Stmt = OCIParse ($Conn, "select id, text from php_table");
OCIExecute ($Stmt);
$rows = OCIFetchStatement ($Stmt, $rs);
print_r ($rs);
?>
output:
OCIDebug: oci_parse "begin php_test (1, :buffer); end;" id=3 conn=2
OCIDebug: oci_new_desc 4
OCIDebug: OCIsavedesc: size=11 offset=1
Warning: OCILobWrite: OCI_INVALID_HANDLE in
/disk/1/home/dbenson/htdocs/hack.php on line 9
Warning: OCIStmtExecute: ORA-22275: invalid LOB locator specified ORA-06512:
at "VIGNETTE.PHP_TEST", line 4 ORA-06512: at line 1 in
/disk/1/home/dbenson/htdocs/hack.php on line 10
OCIDebug: oci_parse "begin php_test (2, :buffer); end;" id=5 conn=2
Warning: OCIStmtExecute: ORA-06550: line 1, column 7: PLS-00306: wrong
number or types of arguments in call to 'PHP_TEST' ORA-06550: line 1, column
7: PL/SQL: Statement ignored in /disk/1/home/dbenson/htdocs/hack.php on line
14
OCIDebug: oci_parse "select id, text from php_table" id=6 conn=2
OCIDebug: START _oci_stmt_list_dtor: id=3 last_query="begin php_test (1,
:buffer); end;"
OCIDebug: _oci_bind_hash_dtor:
OCIDebug: END _oci_stmt_list_dtor: id=3
OCIDebug: oci_new_desc 7
OCIDebug: OCIloadlob: size=14
OCIDebug: START _oci_column_hash_dtor: ID
OCIDebug: END _oci_column_hash_dtor: ID
OCIDebug: START _oci_column_hash_dtor: TEXT
OCIDebug: START _oci_descriptor_list_dtor: 7
OCIDebug: END _oci_descriptor_list_dtor: 7
OCIDebug: END _oci_column_hash_dtor: TEXT
Array ( [ID] => Array ( [0] => 0 ) [TEXT] => Array ( [0] => this is a
clob ) )
Any suggestions on where to go next? Thanks!
David