Re: DBI bind_param_inout question

[email protected] (Martin Evans)
Newsgroups perl.dbi.users
Organization Easysoft Limited
Message-ID <[email protected]>
John Scoles wrote:
> Silly me you do need it so rare that I use it day to day.
>  
> In my case I usualy use it like this
> 
>    $c->bind_param_inout(":p_new_id",\$p_new_id,SQL_DECIMAL);
> 

I think you mean

$c->bind_param_inout(":p_new_id",\$p_new_id,$length,SQL_DECIMAL);

as the $length is compulsory but the bind type (SQL_DECIMAL) is optional.

> 
> or more properly
> 
>  $c->bind_param_inout(":p_new_id",\$p_new_id,ORA_NUMBER);
> 
$c->bind_param_inout(":p_new_id",\$p_new_id,$length, ORA_NUMBER)

> 
> basiclly not to get into the low down stuff in OCI we have to tell OCIBindByName how many bytes to expect for this bind.
>  

As it does in DBD::ODBC. If for instances, you said $length was 10 then
the output bound parameter was 20 bytes in length you'd get a data right
truncation error in DBD::ODBC.

There is however one possible area of ambiguity with respect to bytes or
characters (within a DBD). DBD::ODBC counts the $length as characters
not bytes as how it is eventually encoded in Perl should not matter. So
if you specify $length=10 and the output parameter is a wide (MS's term
in ODBC for a unicode character that occupies 2 bytes) character type
DBD::ODBC allocates twice as much plus 2 (for the terminating nul chr)
bytes then encodes it in UTF-8 for Perl - so you'd get at most 10 chrs.
In this case if the output parameter was 11 chrs in length you'd get a
data right truncation error again.

I'm not sure what DBD::Oracle does wrt to chrs or bytes.

> from the OCI doc
> 
> 'The size in bytes of the data value pointed to by dvoid pointer valuepThe size in bytes of the data value pointed to by dvoid pointer valuep" 
> 
> Hope this helps.
> 
> cheers

Martin
-- 
Martin J. Evans
Easysoft Limited
http://www.easysoft.com

>> CC: [email protected]
>> From: [email protected]
>> To: [email protected]
>> Subject: Re: DBI bind_param_inout question
>> Date: Mon, 8 Mar 2010 17:11:34 -0700
>>
>>
>> On Mar 8, 2010, at 4:52 PM, John Scoles wrote:
>>
>>> depends on the DBD::Driver implimentation.
>>>
>>>
>>>
>>> In DBD::Oracle the maxlenth usually means nothing. Not sure about 
>>> other drivers.
>>>
>>>
>>>
>>> which one are you using?
>>>
>> I'm using oracle. I get an error if I don't include it, but from what 
>> you're saying it's just a dummy value, it just has to have a value?
>>
>> -- 
>> Bruce Johnson
>> University of Arizona
>> College of Pharmacy
>> Information Technology Group
>>
>> Institutions do not have opinions, merely customs
>>
>>
>  		 	   		  
> _________________________________________________________________
> Take your contacts everywhere
> http://go.microsoft.com/?linkid=9712959
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.