Re: Re: Binding LOB input value to stored procedure with PDO_OCI
| From: | Jessie Hernandez | Date: | Wed, 03 Jan 2007 21:30:52 +0000 |
| Subject: | Re: Re: Binding LOB input value to stored procedure with PDO_OCI | ||
| References: | 1 2 3 4 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-4437@lists.php.net to get a copy of this message | ||
Oops, forgot to send it as a MIME attachment (I hate Outlook Express!). Attached as a MIME attachment.
"Jessie Hernandez" <jrhernandez05@gmail.com> wrote in message news:459B22BE.5010800@gmail.com...
Hi Wez, Let me know if you can see the attachment now. Thanks. Regards, Jessie Hernandez Wez Furlong wrote:--------------------------------------------------------------------------------Hi Jessie, PDO deliberately has only one type for large objects, so the driver will be responsible for handling the textual nature of CLOBs internally, something made easier with the unicode support I'm currently developing for PDO. I'd like to see your patch; please resend it as a MIME attachment. Thanks! --Wez. On 1/2/07, Jessie Hernandez <jrhernandez05@gmail.com> wrote:I'm trying to bind a LOB value to a stored procedure call in Oracle.Hello, The current code had PARAM_LOB values hardcoded as BLOBs (hence not allowing CLOBs to be bound) and did not allow LOBs to be passed as input to stored procedures. The attached patch fixes these two issues (please let me know if it should instead be attached to the bug report described below). The fix was done by adding three new class constants, PDO_OCI_PARAM_B_BLOB, PDO_OCI_PARAM_B_CLOB, and PDO_OCI_PARAM_CREATE_TEMP_LOB. PDO_OCI_PARAM_B_CLOB indicates that the value that will be bound is a CLOB instead of a BLOB. PDO_OCI_PARAM_CREATE_TEMP_LOB indicates that a temporary LOB should be created and passed as input (instead of waiting for the LOB to be created and returned via a RETURNING clause). Since a new flag is needed to create a temporary LOB, there are no BC breaks for existing Oracle code. The following is a sample of how calling a stored procedure with an input CLOB would look like: -- ORACLE CREATE OR REPLACE PROCEDURE TEST_PDO(value IN CLOB) AS BEGIN insert into pdoclob values( dbms_lob.substr( value, 50 ) ); END; -- PHP <?php $connection = new PDO( 'oci:dbname=mydb', 'user', 'pass' ); $clob = fopen( '/tmp/testpdo.txt', 'rb' ); $s = $connection->prepare( 'begin test_pdo( ? ); end;' ); $s->bindParam( 1, $clob, PDO::PARAM_LOB, 0, PDO::OCI_PARAM_B_CLOB | PDO::OCI_PARAM_CREATE_TEMP_LOB ); $connection->beginTransaction(); $s->execute(); $connection->commit(); ?> Also, if these same flags are used, you can even insert a clob into a table using "insert into clob_table values( ? )" syntax instead of using "insert into clob_table values(empty_clob()) returning clob_column into ?" syntax! Please let me know if there is anything that needs to be improved in the attached patch (BTW, this patch would also close this bug: http://pecl.php.net/bugs/bug.php?id=7943 ). Thanks! Regards, Jessie Hernandez ""Jessie Hernandez"" <jrhernandez05@gmail.com> wrote in message news:90.10.10210.C8E13854@pb1.pair.com...there is no RETURNING clause for a stored procedure call, I cannotSinceEMPTY_CLOB() trick that's in the documentation. I've tried several things (including creating a CLOB in anotheruse theusing the DBMS_LOB.CREATETEMPORARY method), but nothing has worked.statementsome sample code of what I'm trying to do. With the oic8 extension, one would first have to create a BLOB using the oci_new_descriptorHere'sthen bind that to the statement. Since there's no "oci_new_descriptor" equivalent in PDO_OCI, I cannot create the CLOB beforehand. Is the following possible for PDO_OCI? --- STORED PROCEDURE --- create procedure test_clob(value in clob); --- PHP CODE --- <?php $connection = new PDO( 'oci:dbname=mydb' ); $clob = fopen( 'myfile', 'r' ); $statement = $connection->prepare( 'begin test_clob( ? ); end;' ); $statement->bindParam( 1, $clob, PDO::PARAM_LOB ); $statement->execute(); /* above generates an error: SQLSTATE[HY000]: General error: 6550 OCIStmtExecute: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'TEST_CLOB' */ ?> If the above is not possible with Oracle, can a method be provided to create descriptors only for the PDO_OCI extension? I'm willing to helpfunction,this, as the logic would be the same as the one in the oci8 extension. Please let me know. Thanks. Regards, Jessie Hernandezimplementbegin 666 oci_lob.patch M9&EF9B M=2!P9&]?;V-I7V)A:R]O8VE?<W1A=&5M96YT+F,@<&1O7V]C:2]O M8VE?<W1A=&5M96YT+F,*+2TM('!D;U]O8VE?8F%K+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R!I<R!N;W<@ M86X@3T-)3&]B3&]C871O<B J("HO"BT)"0D)"0E0+3YO8VE?='EP92 ](%-1 M3%1?0DQ/0CL**PD)"0D)"5 M/F]C:5]T>7!E(#T@;&]B7V%L;&]C7W1Y<&4[ M"B )"0D)"0EV86QU95]S>B ]('-I>F5O9BA/0TE,;V),;V-A=&]R*BD["B ) M"0D)"0EB<F5A:SL*( I 0" M,S U+#D@*S,T,RPT,R! 0 H@"0D)"5 M/G5S M961?9F]R7V]U='!U=" ](# ["B )"0D):68@*%!$3U]005)!35]465!%*'!A M<F%M+3YP87)A;5]T>7!E*2 ]/2!01$]?4$%204U?3$]"*2"0D)"6-H87(@8W)E871E9%]T96UP(#T@,#L**PH@ M"0D)"0E35$U47T-!3$PH3T-)1&5S8W)I<'1O<D%L;&]C+" H4RT^2"T^96YV M+" F4"T^=&AI;F<L($]#25]$5%E015],3T(L(# L($Y53$PI*3L*+0D)"0D) M4U1-5%]#04Q,*$]#24%T=')3970L("A0+3YT:&EN9RP@3T-)7T1465!%7TQ/ M0BP@)F5M<'1Y+" P+"!/0TE?05144E],3T)%35!462P@4RT^97)R*2D["B ) M"0D)"5,M/FAA=F5?8FQO8G,@/2 Q.PHK"BL)"0D)"6EF("A:7U194$5?4"AP M87)A;2T^<&%R86UE=&5R*2 A/2!)4U].54Q,*2!["BL)"0D)"0EC:&%R(&-R M96%T95]T96UP7VQO8B ](# ["BL)"0D)"0EU8C$@;&]B7W1Y<&4@/2!/0TE? M5$5-4%]"3$]".PHK"0D)"0D)<&AP7W-T<F5A;2 J<W1M(#T@3E5,3#L**PHK M"0D)"0D):68@*%I?5%E015]0*'!A<F%M+3YD<FEV97)?<&%R86US*2 A/2!) M4U].54Q,*2!["BL)"0D)"0D)8V]N=F5R=%]T;U]L;VYG*'!A<F%M+3YD<FEV M97)?<&%R86US*3L**PHK"0D)"0D)"6EF("@H6E],5D%,7U H<&%R86TM/F1R M:79E<E]P87)A;7,I("8@4$1/7T]#25]005)!35]"7T-,3T(I(#T](%!$3U]/ M0TE?4$%204U?0E]#3$]"*0HK"0D)"0D)"0EL;V)?='EP92 ]($]#25]414U0 M7T-,3T(["BL**PD)"0D)"0EI9B H*%I?3%9!3%]0*'!A<F%M+3YD<FEV97)? M<&%R86US*2 F(%!$3U]/0TE?4$%204U?0U)%051%7U1%35!?3$]"*2 ]/2!0 M1$]?3T-)7U!!4D%-7T-214%415]414U07TQ/0BD**PD)"0D)"0D)8W)E871E M7W1E;7!?;&]B(#T@,3L**PD)"0D)"7T**PHK"0D)"0D):68@*&-R96%T95]T M96UP7VQO8BD@>PHK"0D)"0D)"7!H<%]S=')E86U?9G)O;5]Z=F%L7VYO7W9E M<FEF>2AS=&TL("9P87)A;2T^<&%R86UE=&5R*3L**PHK"0D)"0D)"6EF("AS M=&TI('L**PD)"0D)"0D)4U1-5%]#04Q,*$]#24QO8D-R96%T951E;7!O<F%R M>2P@*%,M/D@M/G-V8RP@4RT^97)R+ HK"0D)"0D)"0D)"0DH3T-)3&]B3&]C M871O<BHI4"T^=&AI;F<L($]#25]$149!54Q4+"!/0TE?1$5&055,5"P**PD) M"0D)"0D)"0D);&]B7W1Y<&4L($]#25]!5%127TY/0T%#2$4L($]#25]$55)! M5$E/3E]315-324].*2D["BL**PD)"0D)"0D);V-I7W=R:71E7VQO8E]F<F]M M7W-T<F5A;2A3+"!0+"!S=&TI.PHK"0D)"0D)"0EP<FEN=&8H(F%F=&5R(&]C M:5]W<FET95]L;V)?9G)O;5]S=')E86T@-5QN(BD["BL)"0D)"0D)"6-R96%T M961?=&5M<" ](#$["BL)"0D)"0D)?0HK"0D)"0D)?0HK"0D)"0E]"BL**PD) M"0D):68@*"%C<F5A=&5D7W1E;7 I"BL)"0D)"0E35$U47T-!3$PH3T-)071T M<E-E="P@*% M/G1H:6YG+"!/0TE?1%194$5?3$]"+" F96UP='DL(# L($]# M25]!5%127TQ/0D5-4%19+"!3+3YE<G(I*3L*( D)"0E]"B )"0D)<F5T=7)N M(#$["B *0$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7V]C:5]I;G0N:"!P M9&]?;V-I+W!H<%]P9&]?;V-I7VEN="YH"BTM+2!P9&]?;V-I7V)A:R]P:'!? M<&1O7V]C:5]I;G0N: DR,# W+3 Q+3 R(#$X.C$W.C U+C$V-C<X-C0T," M M,#4P, HK*RL@<&1O7V]C:2]P:'!?<&1O7V]C:5]I;G0N: DR,# W+3 Q+3 R M(#$X.C(U.C0W+C0W-#,X,S8Q-B M,#4P, I 0" M.3(L,R K.3(L.2! 0 H@ M#0H@97AT97)N('-T<G5C="!P9&]?<W1M=%]M971H;V1S(&]C:5]S=&UT7VUE M=&AO9',[#0H@#0HK96YU;2!P9&]?;V-I7W!A<F%M('L-"BL)4$1/7T]#25]0 M05)!35]"7T),3T(@/2 P># Q+ T**PE01$]?3T-)7U!!4D%-7T)?0TQ/0B ] M(#!X,#(L#0HK"5!$3U]/0TE?4$%204U?0U)%051%7U1%35!?3$]"(#T@,'@P ,-"P-"BM].PT**PT* ` end -- PECL development discussion Mailing List (http://pecl.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
diff -u pdo_oci_bak/oci_statement.c pdo_oci/oci_statement.c --- pdo_oci_bak/oci_statement.c 2007-01-02 18:16:52.589698448 -0500 +++ pdo_oci/oci_statement.c 2007-01-02 18:17:23.000075368 -0500 @@ -235,6 +235,36 @@ return OCI_CONTINUE; } /* }}} */ +static void oci_write_lob_from_stream(pdo_oci_stmt *S, pdo_oci_bound_param *P, php_stream *stm) +{ + size_t n; + ub4 amt, offset = 1; + char *consume; + + OCILobOpen(S->H->svc, S->err, (OCILobLocator*)P->thing, OCI_LOB_READWRITE); + + do { + char buf[8192]; + n = php_stream_read(stm, buf, sizeof(buf)); + if ((int)n <= 0) { + break; + } + consume = buf; + do { + amt = n; + OCILobWrite(S->H->svc, S->err, (OCILobLocator*)P->thing, + &amt, offset, consume, n, + OCI_ONE_PIECE, + NULL, NULL, 0, SQLCS_IMPLICIT); + offset += amt; + n -= amt; + consume += amt; + } while (n); + } while (1); + OCILobClose(S->H->svc, S->err, (OCILobLocator*)P->thing); + OCILobFlushBuffer(S->H->svc, S->err, (OCILobLocator*)P->thing, 0); +} + static int oci_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, enum pdo_param_event event_type TSRMLS_DC) /* {{{ */ { pdo_oci_stmt *S = (pdo_oci_stmt*)stmt->driver_data; @@ -243,6 +273,7 @@ if (param->is_param) { pdo_oci_bound_param *P; sb4 value_sz = -1; + sb2 lob_alloc_type = SQLT_BLOB; P = (pdo_oci_bound_param*)param->driver_data; @@ -264,8 +295,15 @@ return 0; case PDO_PARAM_LOB: + if (param->driver_params != NULL) { + convert_to_long(param->driver_params); + + if ((Z_LVAL_P(param->driver_params) & PDO_OCI_PARAM_B_CLOB) == PDO_OCI_PARAM_B_CLOB) + lob_alloc_type = SQLT_CLOB; + } + /* P->thing is now an OCILobLocator * */ - P->oci_type = SQLT_BLOB; + P->oci_type = lob_alloc_type; value_sz = sizeof(OCILobLocator*); break; @@ -305,9 +343,43 @@ P->used_for_output = 0; if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_LOB) { ub4 empty = 0; + char created_temp = 0; + STMT_CALL(OCIDescriptorAlloc, (S->H->env, &P->thing, OCI_DTYPE_LOB, 0, NULL)); - STMT_CALL(OCIAttrSet, (P->thing, OCI_DTYPE_LOB, &empty, 0, OCI_ATTR_LOBEMPTY, S->err)); S->have_blobs = 1; + + if (Z_TYPE_P(param->parameter) != IS_NULL) { + char create_temp_lob = 0; + ub1 lob_type = OCI_TEMP_BLOB; + php_stream *stm = NULL; + + if (Z_TYPE_P(param->driver_params) != IS_NULL) { + convert_to_long(param->driver_params); + + if ((Z_LVAL_P(param->driver_params) & PDO_OCI_PARAM_B_CLOB) == PDO_OCI_PARAM_B_CLOB) + lob_type = OCI_TEMP_CLOB; + + if ((Z_LVAL_P(param->driver_params) & PDO_OCI_PARAM_CREATE_TEMP_LOB) == PDO_OCI_PARAM_CREATE_TEMP_LOB) + create_temp_lob = 1; + } + + if (create_temp_lob) { + php_stream_from_zval_no_verify(stm, ¶m->parameter); + + if (stm) { + STMT_CALL(OCILobCreateTemporary, (S->H->svc, S->err, + (OCILobLocator*)P->thing, OCI_DEFAULT, OCI_DEFAULT, + lob_type, OCI_ATTR_NOCACHE, OCI_DURATION_SESSION)); + + oci_write_lob_from_stream(S, P, stm); + printf("after oci_write_lob_from_stream 5\n"); + created_temp = 1; + } + } + } + + if (!created_temp) + STMT_CALL(OCIAttrSet, (P->thing, OCI_DTYPE_LOB, &empty, 0, OCI_ATTR_LOBEMPTY, S->err)); } return 1; @@ -357,27 +429,7 @@ php_stream_from_zval_no_verify(stm, ¶m->parameter); if (stm) { - OCILobOpen(S->H->svc, S->err, (OCILobLocator*)P->thing, OCI_LOB_READWRITE); - do { - char buf[8192]; - n = php_stream_read(stm, buf, sizeof(buf)); - if ((int)n <= 0) { - break; - } - consume = buf; - do { - amt = n; - OCILobWrite(S->H->svc, S->err, (OCILobLocator*)P->thing, - &amt, offset, consume, n, - OCI_ONE_PIECE, - NULL, NULL, 0, SQLCS_IMPLICIT); - offset += amt; - n -= amt; - consume += amt; - } while (n); - } while (1); - OCILobClose(S->H->svc, S->err, (OCILobLocator*)P->thing); - OCILobFlushBuffer(S->H->svc, S->err, (OCILobLocator*)P->thing, 0); + oci_write_lob_from_stream(S, P, stm); } else if (Z_TYPE_P(param->parameter) == IS_STRING) { /* stick the string into the LOB */ consume = Z_STRVAL_P(param->parameter); diff -u pdo_oci_bak/pdo_oci.c pdo_oci/pdo_oci.c --- pdo_oci_bak/pdo_oci.c 2007-01-02 18:17:13.887460696 -0500 +++ pdo_oci/pdo_oci.c 2007-01-02 18:17:40.317442728 -0500 @@ -90,6 +90,9 @@ */ PHP_MINIT_FUNCTION(pdo_oci) { + REGISTER_PDO_CLASS_CONST_LONG("OCI_PARAM_B_BLOB", (long)PDO_OCI_PARAM_B_BLOB); + REGISTER_PDO_CLASS_CONST_LONG("OCI_PARAM_B_CLOB", (long)PDO_OCI_PARAM_B_CLOB); + REGISTER_PDO_CLASS_CONST_LONG("OCI_PARAM_CREATE_TEMP_LOB", (long)PDO_OCI_PARAM_CREATE_TEMP_LOB); php_pdo_register_driver(&pdo_oci_driver); #if HAVE_OCIENVCREATE diff -u pdo_oci_bak/php_pdo_oci_int.h pdo_oci/php_pdo_oci_int.h --- pdo_oci_bak/php_pdo_oci_int.h 2007-01-02 18:17:05.166786440 -0500 +++ pdo_oci/php_pdo_oci_int.h 2007-01-02 18:25:47.474383616 -0500 @@ -92,3 +92,9 @@ extern struct pdo_stmt_methods oci_stmt_methods; +enum pdo_oci_param { + PDO_OCI_PARAM_B_BLOB = 0x01, + PDO_OCI_PARAM_B_CLOB = 0x02, + PDO_OCI_PARAM_CREATE_TEMP_LOB = 0x04, +}; +