Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> sql queries and bind variables

sql queries and bind variables

From: silvia.fama <silvia.fama_at_googlemail.com>
Date: 19 Jan 2007 10:28:57 -0800
Message-ID: <1169231336.889419.248240@51g2000cwl.googlegroups.com>


Hi!
I'd liek to understand why oracle changes its behaviour when using bind variables.
I try to explain.
If I have a char column (e.g. COLUMN1 is char(50)), I can execute succesfully a select as:
select * from TABLE1 where COLUMN1 = 'silvia' also if the length of "silvia" is less then 50. With this kind of select oracle knows to right trim blank values. Instead if I use bind variables:
select * from TABLE1 where COLUMN1 = :NAME where :NAME is "silvia"
Oracle doesn't recognize "silvia" but I need to RTRIM the column: select * from TABLE1 where RTRIM(COLUMN1) = :NAME

Why there is a different behaviour?

I use:

errora = OCIBindByPos (	dbproc_ora9->oci_stmtp			,
		&bndpp							,
		dbproc_ora9->oci_err			,

(ub4)(j+1) ,
(dvoid *) name ,
(sb4)datalen ,
(ub2)datatype ,
(dvoid *) 0 ,
(ub2 *) 0 ,
(ub2 *) 0 ,
(ub4) 0 ,
(ub4 *) 0 ,
(ub4) OCI_DEFAULT
) ;

I tried two things:
first:
name is "silvia"
datalen is 6
and datatype is SQLT_CHAR

second;
name is "silvia\0"
datalen is 7
datatype is SQLT_STR

no difference; query finds "silvia" only in the second case and if I use RTRIM.

May someone explain it to me?

Thank you! Received on Fri Jan 19 2007 - 12:28:57 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US