apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoffrey Giesemann <geof...@cs.rmit.edu.au>
Subject Re: DBD: Prepared statements, BLOBs etc.
Date Thu, 18 Jan 2007 03:17:07 GMT
On Thu, Jan 18, 2007 at 01:37:49PM +1100, Bojan Smojver wrote:
> 
> Well, I'm facing some major grief regarding this. I found another
> example, which would suggest more or less the same thing here, but using
> SQLT_CHR type:
> 
> http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14249/adlob_data_interface.htm
> 
> The text and code is:
> 
> ----------------------------------
> Binding LONG Data for LOB Columns in Binds Greater Than 4000 Bytes
> 
> The following example illustrates binding character data for a LOB
> column:
> 
> void simple_insert()
> {
>   word buflen;
>   text buf[5000];
>   text *insstmt = (text *) "INSERT INTO Print_media(Product_id, Ad_id,\
>                   Ad_sourcetext) VALUES (2004, 1, :SRCTXT)";
>  
>   OCIStmtPrepare(stmthp, errhp, insstmt, (ub4)strlen((char *)insstmt), 
>                 (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT);
>   
>   OCIBindByName(stmthp, &bndhp[0], errhp,
>                 (text *) ":SRCTXT", (sb4) strlen((char *) ":SRCTXT"),
>                 (dvoid *) buf, (sb4) sizeof(buf), SQLT_CHR,
>                 (dvoid *) 0, (ub2 *) 0, (ub2 *) 0,
>                 (ub4) 0, (ub4 *) 0, (ub4) OCI_DEFAULT);
>  
>   memset((void *)buf, (int)'A', (size_t)5000);
>   OCIStmtExecute(svchp, stmthp, errhp, (ub4) 1, (ub4) 0,
>                  (const OCISnapshot*) 0, (OCISnapshot*) 0, (ub4) OCI_DEFAULT);
> }
> ----------------------------------
> 

(This is more of an Oracle query than an APR query, but here goes)

What's the actual type of the Ad_sourcetext column?

Can you try:

INSERT INTO Print_media(Product_id, Ad_id, Ad_sourcetext VALUES
 (2004, 1, TO_LOB(:SRCTXT))
           ^^^^^^

instead?

> 
> ----------------------------------
> Execute error -1: ORA-01461: can bind a LONG value only for insert into
> a LONG column
> ----------------------------------
>
>
> Values up to and including 4000 bytes work fine (minus the character
> conversion bit, which I still need to figure out). The error appears
> with 4001+ bytes.
>

This suggests that the implicit data type for :SRCTXT is a LONG (for
some reason).  Is there a more specific bind type you could use? (other
than SQLT_CHR)

(I will disclaim that I've never done any C-based OCI programming
before, but I do know my way around Oracle)

--Geoff

Mime
View raw message