DBD-Oracle

 view release on metacpan or  search on metacpan

oci8.c  view on Meta::CPAN

dbd_phs_in(dvoid *octxp, OCIBind *bindp, ub4 iter, ub4 index,
		  dvoid **bufpp, ub4 *alenp, ub1 *piecep, dvoid **indpp)
{
	dTHX;
	phs_t *phs = (phs_t*)octxp;
	STRLEN phs_len;
	AV *tuples_av;
	SV *sv;
	AV *av;
	SV **sv_p;
	if( bindp ){ /* For GCC not to warn on unused parameter*/ }

	tuples_av = phs->imp_sth->bind_tuples;
	if(tuples_av) {
		/* NOTE: we already checked the validity in ora_st_bind_for_array_exec(). */
		sv_p = av_fetch(tuples_av, phs->imp_sth->rowwise ? (int)iter : phs->idx, 0);
		av = (AV*)SvRV(*sv_p);
		sv_p = av_fetch(av, phs->imp_sth->rowwise ? phs->idx : (int)iter, 0);
		sv = *sv_p;
		if(SvOK(sv)) {
			*bufpp = SvPV(sv, phs_len);
			phs->alen = (phs->alen_incnull) ? phs_len+1 : phs_len;
			phs->indp = 0;
		}
		else {
			*bufpp = SvPVX(sv);
			phs->alen = 0;
			phs->indp = -1;
		}
	}
	else
		if (phs->desc_h) {
			*bufpp  = phs->desc_h;
			phs->alen = 0;
			phs->indp = 0;
		}
		else
			if (SvOK(phs->sv)) {
				*bufpp  = SvPV(phs->sv, phs_len);
				phs->alen = (phs->alen_incnull) ? phs_len+1 : phs_len;;
				phs->indp = 0;
			}
			else {
				*bufpp  = SvPVX(phs->sv);	/* not actually used? */
				phs->alen = 0;
				phs->indp = -1;
			}
	*alenp  = phs->alen;
	*indpp  = &phs->indp;
	*piecep = OCI_ONE_PIECE;
	/* MJE commented out as we are avoiding DBIS now but as this is
	   an Oracle callback there is no way to pass something non
	   OCI into this func.

	if (DBIS->debug >= 3 || dbd_verbose >= 3 )
		PerlIO_printf(DBILOGFP, "		in  '%s' [%lu,%lu]: len %2lu, ind %d%s, value=%s\n",
			phs->name, ul_t(iter), ul_t(index), ul_t(phs->alen), phs->indp,
			(phs->desc_h) ? " via descriptor" : "",neatsvpv(phs->sv,10));
	*/
	if (!tuples_av && (index > 0 || iter > 0))
		croak(" Arrays and multiple iterations not currently supported by DBD::Oracle (in %d/%d)", index,iter);

	return OCI_CONTINUE;
}

/*
``Binding and Defining''

Binding RETURNING...INTO variables

As mentioned in the previous section, an OCI application implements the placeholders in the RETURNING clause as
pure OUT bind variables. An application must adhere to the following rules when working with these bind variables:

  1.Bind RETURNING clause placeholders in OCI_DATA_AT_EXEC mode using OCIBindByName() or
	OCIBindByPos(), followed by a call to OCIBindDynamic() for each placeholder.

	Note: The OCI only supports the callback mechanism for RETURNING clause binds. The polling mechanism is
	not supported.

  2.When binding RETURNING clause placeholders, you must supply a valid out bind function as the ocbfp
	parameter of the OCIBindDynamic() call. This function must provide storage to hold the returned data.
  3.The icbfp parameter of OCIBindDynamic() call should provide a "dummy" function which returns NULL values
	when called.
  4.The piecep parameter of OCIBindDynamic() must be set to OCI_ONE_PIECE.
  5.No duplicate binds are allowed in a DML statement with a RETURNING clause (i.e., no duplication between bind
	variables in the DML section and the RETURNING section of the statement).

When a callback function is called, the OCI_ATTR_ROWS_RETURNED attribute of the bind handle tells the
application the number of rows being returned in that particular iteration. Thus, when the callback is called the first
time in a particular iteration (i.e., index=0), the user can allocate space for all the rows which will be returned for that
bind variable. When the callback is called subsequently (with index>0) within the same iteration, the user can merely
increment the buffer pointer to the correct memory within the allocated space to retrieve the data.

Every bind handle has a OCI_ATTR_MAXDATA_SIZE attribute. This attribute specifies the number of bytes to be
allocated on the server to accommodate the client-side bind data after any necessary character set conversions.

	Note: Character set conversions performed when data is sent to the server may result in the data expanding or
	contracting, so its size on the client may not be the same as its size on the server.

An application will typically set OCI_ATTR_MAXDATA_SIZE to the maximum size of the column or the size of the
PL/SQL variable, depending on how it is used. Oracle issues an error if OCI_ATTR_MAXDATA_SIZE is not a large
enough value to accommodate the data after conversion, and the operation will fail.
*/

sb4
dbd_phs_out(dvoid *octxp, OCIBind *bindp,
	ub4 iter,	/* execution itteration (0...)	*/
	ub4 index,	/* array index (0..)		*/
	dvoid **bufpp,	/* A pointer to a buffer to write the bind value/piece.	*/
	ub4 **alenpp,	/* A pointer to a storage for OCI to fill in the size	*/
			/* of the bind value/piece after it has been read.	*/
	ub1 *piecep,	/* */
	dvoid **indpp,	/* Return a pointer to contain the indicator value which either an sb2	*/
			/* value or a pointer to an indicator structure for named data types.	*/
	ub2 **rcodepp)	/* Returns a pointer to contains the return code.	*/
{
	dTHX;
	phs_t *phs = (phs_t*)octxp;	/* context */
	/*imp_sth_t *imp_sth = phs->imp_sth;*/
	if( bindp ) { /* For GCC not to warn on unused parameter */ }



( run in 1.509 second using v1.01-cache-2.11-cpan-71847e10f99 )