Re: Clarification sought on private_attribute_info WAS Re: DBD::Oracle 11gr2 ORA-38909

2010-05-10 Thread Tim Bunce
[Sorry for the delay]

On the one hand, the DBI makes a distinction between method attributes
and handle attributes. They're different things.

On the other hand, the handle constructor methods are a special case.
The method attributes passed to connect() are applied to the newly
created dbh as handle attributes.

The same _ought_ to be true of prepare() but isn't, sadly. This is one
of those areas of the DBI where the risk of breakage now far outweighs
the gains from trying to fix it.

So, to answer your question Martin, I'll update the docs to clarify that
it applies to handle attributes.

Tim.

On Fri, May 07, 2010 at 04:35:32PM +0100, Martin Evans wrote:
 Apologies for top posting but this is an old thread and I include it for
 reference but really I'd like some clarification from Tim as to whether
 the following is correct.
 
 As John states the DBI documentation says for private_attribute_info:
 
 Returns a reference to a hash whose keys are the names of
 driver-private attributes available for the kind of handle (driver,
 database, statement) that the method was called on.
 
 My question is does this include attributes which may be specified on
 the prepare call when there is no separate store/fetch on the handle. e.g.,
 
 $h-prepare(select 1 from dual, {ora_parse_lang = 2});
 
 You cannot set ora_parse_lang on a $sth or retrieve it so should it be
 in private_attribute_info?
 
 I would like to know since if ora_parse_lang in DBD::Oracle should be in
 private_attribute_info when it cannot be independently stored or fetched
 then this impacts similar prepare attributes in DBD::ODBC.
 
 Martin
 -- 
 Martin J. Evans
 Easysoft Limited
 http://www.easysoft.com
 
 
 John Scoles wrote:
  
  
  On Tue, Apr 6, 2010 at 4:51 AM, Martin Evans martin.ev...@easysoft.com
  mailto:martin.ev...@easysoft.com wrote:
  
  I haven't seen a reply to this yet but I've been on holiday so might
  have missed it:
  
  Scott T. Hildreth wrote:
   On Wed, 2010-03-31 at 12:20 -0500, Scott T. Hildreth wrote:
   We have run into an issue with array processing in 11g.  The
  developer
   was using execute_array and his sql statement had 'LOG ERRORS' in it.
   This did not error out until we switched to 11g.  The issue is
  that only
   one is allowed, either 'LOG ERRORS' or 'SAVE EXCEPTIONS'.  Our DBA
   logged and error report with Oracle and after several posts back and
   forth this is what they concluded,
  
  
  ==
   After investigation and discussion, development has closed the bug as
   'Not a Bug' with the following reason:
  
   this is an expected behavior in 11g and the user needs to specify
   either of 'SAVE EXCEPTIONS' clause or the 'DML error logging',
  but NOT
   both together.
   The batch error mode, in the context of this bug, is basically
  referring
   to the SAVE EXCEPTIONS clause.
   It seems the code is trying to use both dml error logging and batch
   error handling for the same insert. In that case, this is not a bug.
  
   For INSERT, the data errors are logged in an error logging table
  (when
   the dml error logging feature is used) or returned in batch error
   handles (when using batch mode).
   Since the error messages are available to the user in either
  case, there
   is no need to both log the error in the error logging table and
  return
   the errors in batch error handles,
   and we require the user to specify one option or the other but
  not both
   in 11G.
  
   Both features exist in 10.x. For 11.x, users should change their
   application to avoid the error.
  
  ==
  
   So basically we need a way to turn off the 'SAVE EXCEPTIONS' for the
   batch mode.  I found in dbdimp.c that the oci_mode is being set to
   OCI_BATCH_ERRORS in the ora_st_execute_array function.  I was
  planning
   on setting it to OCI_BATCH_MODE and running a test to see if this
  will
   not error out.  I report back when I have run the test, but I was
   wondering what would be the best way to give the user the ability to
   override the oci_mode.
  
   Setting oci_mode to OCI_BATCH_MODE works.  So I want to add a prepare
   attribute that will turn off the SAVE EXCEPTIONS.  I'm looking for
  some
   direction on how to add it to dbdimp.c. I haven't thought of a
  name yet,
   but something like
  
   my $sth = $dbh-prepare($SQL,{ora_oci_err_mode = 0});
  
   I assume I would have to add it to dbd_db_FETCH_attrib() and would
  I do
   something like this in ora_st_execute_array(),
  
  Don't you mean dbd_st_FETCH_attrib as it is a statement level attribute
  not a connection one? Anyway, I don't think 

Clarification sought on private_attribute_info WAS Re: DBD::Oracle 11gr2 ORA-38909

2010-05-07 Thread Martin Evans
Apologies for top posting but this is an old thread and I include it for
reference but really I'd like some clarification from Tim as to whether
the following is correct.

As John states the DBI documentation says for private_attribute_info:

Returns a reference to a hash whose keys are the names of
driver-private attributes available for the kind of handle (driver,
database, statement) that the method was called on.

My question is does this include attributes which may be specified on
the prepare call when there is no separate store/fetch on the handle. e.g.,

$h-prepare(select 1 from dual, {ora_parse_lang = 2});

You cannot set ora_parse_lang on a $sth or retrieve it so should it be
in private_attribute_info?

I would like to know since if ora_parse_lang in DBD::Oracle should be in
private_attribute_info when it cannot be independently stored or fetched
then this impacts similar prepare attributes in DBD::ODBC.

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


John Scoles wrote:
 
 
 On Tue, Apr 6, 2010 at 4:51 AM, Martin Evans martin.ev...@easysoft.com
 mailto:martin.ev...@easysoft.com wrote:
 
 I haven't seen a reply to this yet but I've been on holiday so might
 have missed it:
 
 Scott T. Hildreth wrote:
  On Wed, 2010-03-31 at 12:20 -0500, Scott T. Hildreth wrote:
  We have run into an issue with array processing in 11g.  The
 developer
  was using execute_array and his sql statement had 'LOG ERRORS' in it.
  This did not error out until we switched to 11g.  The issue is
 that only
  one is allowed, either 'LOG ERRORS' or 'SAVE EXCEPTIONS'.  Our DBA
  logged and error report with Oracle and after several posts back and
  forth this is what they concluded,
 
 
 ==
  After investigation and discussion, development has closed the bug as
  'Not a Bug' with the following reason:
 
  this is an expected behavior in 11g and the user needs to specify
  either of 'SAVE EXCEPTIONS' clause or the 'DML error logging',
 but NOT
  both together.
  The batch error mode, in the context of this bug, is basically
 referring
  to the SAVE EXCEPTIONS clause.
  It seems the code is trying to use both dml error logging and batch
  error handling for the same insert. In that case, this is not a bug.
 
  For INSERT, the data errors are logged in an error logging table
 (when
  the dml error logging feature is used) or returned in batch error
  handles (when using batch mode).
  Since the error messages are available to the user in either
 case, there
  is no need to both log the error in the error logging table and
 return
  the errors in batch error handles,
  and we require the user to specify one option or the other but
 not both
  in 11G.
 
  Both features exist in 10.x. For 11.x, users should change their
  application to avoid the error.
 
 ==
 
  So basically we need a way to turn off the 'SAVE EXCEPTIONS' for the
  batch mode.  I found in dbdimp.c that the oci_mode is being set to
  OCI_BATCH_ERRORS in the ora_st_execute_array function.  I was
 planning
  on setting it to OCI_BATCH_MODE and running a test to see if this
 will
  not error out.  I report back when I have run the test, but I was
  wondering what would be the best way to give the user the ability to
  override the oci_mode.
 
  Setting oci_mode to OCI_BATCH_MODE works.  So I want to add a prepare
  attribute that will turn off the SAVE EXCEPTIONS.  I'm looking for
 some
  direction on how to add it to dbdimp.c. I haven't thought of a
 name yet,
  but something like
 
  my $sth = $dbh-prepare($SQL,{ora_oci_err_mode = 0});
 
  I assume I would have to add it to dbd_db_FETCH_attrib() and would
 I do
  something like this in ora_st_execute_array(),
 
 Don't you mean dbd_st_FETCH_attrib as it is a statement level attribute
 not a connection one? Anyway, I don't think it is required unless you
 really want to get it back out in a Perl script.
 
 I don't even think you need to add it to a statements
 private_attribute_info but then when I checked Oracle.pm it appears a
 load of prepare flags have been added. I might be wrong here but since
 there is no way to get ora_parse_lang etc (prepare attributes) I don't
 think they should be in private_attribute_info.
 
 Well it should be in there along with the other ones I forgot to add;)
 
 if one looks at  the dbi spec
 
 
   |private_attribute_info| #___top
 
 Returns a reference to a hash whose keys are the names of driver-private
 attributes available for the kind of handle (driver, database,
 statement) that the method was called on.
 
 
 The values