OCI Bind for RAW field, Cannot select a record matching a hexadecimal Key (raw type)

From: Anand Mamuder <amamuder_at_hersheys.com>
Date: 22 Aug 2003 12:45:18 -0700
Message-ID: <d249fdd4.0308221145.50bd2a44_at_posting.google.com>


Greetings,
I have a table MYTABLE ( msg_id RAW(24) NOT NULL) , .....) msg_id is the key,

If I wanted to select a record using the OCI, the select is failing. I can see that the value exists using sqlplus. I guess I am not doing the Bind correctly.
'414D51204D45525420202020202020203F2293C209CBD012' is a example value for msg_id, obtained from the select in SQLplus, when i use the OCI app
I have the value
char tmp_str[] ="414D51204D45525420202020202020203F2293C209CBD012"); unsigned char mid_var[48];
memcpy(&mid_var,tmp_str,48); //to clear the null termination

select count(*) from MYTABLE where msg_id = :msg_input;

I do allocate the handles, prepare,define and all the other stuff. I do a Bind with
rc = OCIBindByName(p_sql,

		&p_bnd,
		p_err, 
		(text *) ":msg_input",
		 -1, 
		(dvoid *)&mid_var,
		 sizeof(24), //tried with sizeof(48) - doesnt help
		 SQLT_BIN,// tried with SQLT_CHR - doesnt help

(dvoid *) 0,
(ub2 *) 0,
(ub2 *) 0,
(ub4) 0,
(ub4 *) 0, OCI_DEFAULT);

and the execution returns nothing.
PLEASE provide me with sample code that you can bind and retrieve data based off the primary key of RAW type.
Help is greatly appreciated.
Many thanks, Received on Fri Aug 22 2003 - 21:45:18 CEST

Original text of this message