OTL 4.0, OTL defined exceptions

OTL 4.0, OTL defined exceptions

OTL defined exceptions

The following  OTL exceptions  can be raised by the  OTL stream  functions:

Code=32000: Incompatible data types in stream operation

  • Cause: The data type of a variable used in the current stream operation is not compatible with the declared stream format
  • Action: Check placeholders and declarations of their data types
Code=32001: Row must be full for flushing output stream
  • Cause: Stream is open for output and has a format of output rows. An output row is a tuple of all output variables put together. The current output row is not filled yet but the flush function is invoked. The stream buffer cannot be flushed until the current row of the output buffer is full.
  • Action: Fill the row first, then flush the stream.
Code=32004: Not all input variables have been initialized
  • Cause: stream has input variables but not all the variables have been initialized. An attempt to read data from the stream was made.
  • Action: Assign all input variables first.
Code=32004: No input variables have been defined in SQL statement
  • Cause: Stream has no input variables. An attempt to write objects into the stream via one of the operator << was made.
  • Action: Do not call the operator << for streams which have no input variables defined.
Code=32005: Input string value is too large to fit into the buffer
  • Cause: Stream is open for output, e.g. an INSERT statement. The actual string value is larger than the buffer size, e.g. "123456789" is the string and the placeholder was defined as :f2<char[5]>
  • Action: Truncate the input string or increase the size of the buffer of the placeholder <char[10]>
Code=32006: Input otl_long_string value is too large to fit into the buffer
  • Cause: Stream is open for output, e.g. an INSERT statement. The actual otl_long_string is larger than the buffer size, defined by set_max_long_size(), e.g. "123456789" is the long string and the following function call was made set_max_long_size(5).
  • Action: Truncate the input long string or increase the size of the max long size: set_max_long_size(100)
Code=32007: PL/SQL table size is too large (>32767)
  • Cause: Size of PL/SQL.table to be declared in otl_stream is too large.
  • Action: The maximum size of PL/SQL table is limited to 32767 elements.
Code=32008: Writing CLOB/BLOB in stream mode: actual size is greater than specified, trying to store X1 bytes / Unicode characters at offset X2. New length: X3 would be bigger than length of lob: X4. 
  • Cause: Actual number of bytes to be written into the LOB stream is greater than specified in the otl_lob_stream::set_len() function. X1-X4 are specified either in bytes or Unicode characters (in case if #define OTL_UNICODE is used).
  • Action: Actual number of bytes to be written into the LOB stream should match the number, specified in the set_len() function.
Code=32009: Closing CLOB/BLOB in stream mode: actual size is not equal to specified size
  • Cause: When otl_lob_stream::close() is called, it turns out that the number of bytes, written into the LOB stream, does not match the number of bytes, specified in otl_lob_stream::set_len().
  • Action: Actual number of bytes to be written into the LOB stream should match the number, specified in the set_len() function
Code=32010: CLOB/BLOB stream is not open for writing
  • Cause: An attempt was made to write into the LOB stream, which was not initialized for writing.
  • Action: LOB stream that is not open for writing, cannot be used for writing.


Code=32012: CLOB/BLOB stream is not open for reading

  • Cause: An attempt was made to read from the LOB stream, which was not initialized for reading.
  • Action: LOB stream that is not open for reading, cannot be used for reading.


Code=32012: First session must be started with session_begin()

  • Cause: An attempt to call otl_connect::session_reopen() was made, before calling session_begin().
  • Action: Change the logic of the program to call session_begin() first, and only after that to call session_reopen().


Code=32013: Invalid bind variable declaration

  • Cause: There was a typo in the bind variable declaration, e.g. :var<date>, instead of :var<timestamp>. 
  • Action: Correct the typo and try again. In the case of :var<char[1]>, check the minimum acceptable size.


Code=32014: No stored procedure was found

  • Cause: Stored procedure name, being passed into otl_stream::create_stored_proc_call, cannot be found in the Oracle data dictionary.
  • Action: Correct the stored procedure name, and try again.


Code=32015: Unsupported data type

  • Cause: Data type of parameter of the stored procedure, specified in  otl_stream::create_stored_proc_call, is unsupported.
  • Action: PL/SQL tables, as stored procedure parameters, are not supported by create_stored_proc_call(). Also, if a stored procedure, which returns a reference cursor as an output parameter, has INOUT, or OUT parameters, is not supported by create_stored_proc_call(). create_stored_proc_call() supports a limited set of types of stored procedures.
Code=32016: Unsupported procedure type Code=32017: Stream buffer size can't be > 1 in this case
  • Cause: In case if varchar_longraw_long are used in a combination with OTL/OCIx, the only allowed stream buffer size is 1.


    In case if clobblob are used in a combination with OTL/OCIx, the only allowed stream buffer size for INSERTs or UPDATEs is 1. Though, buffer sizes, larger than 1, are allowed for SELECT statements.

    This exception gets raised when the above limitations are violated. 
     

  • Action: Set the buffer size to 1.
Code=32018: ODBC / DB2 CLI function name is not recognized. It should be one of the following: SQLTables, SQLColumns, SQLProcedures, SQLColumnPrivileges, SQLTablePrivileges, SQLPrimaryKeys, SQLProcedureColumns, SQLForeignKeys, SQLStatistics.
  • Cause: A stream is being instantiated with a call to ODBC / DB2 CLI that returns a description of a system table catalog, or a description of table columns (see appendix B for more detail). The function name was not recognized as one from the list above.
     
  • Action: Check the spelling of the function name that is being passed into the stream, fix it, recompile the program, and try again.

Code=32019: otl_stream::operator>>() should have been called before otl_stream::operator int()
  • Cause: One of the otl_stream::operators >>() should have been called before calling otl_stream::operator int(). Operator int() works only for streams that have some output (SELECT statements, stored procedures returning result sets, etc.). Otherwise, the meaning of operator int() is not defined, so the operator returns incorrect values, or values that do not make any sense, and do not reflect anything meaningful. Therefore, this exception gets thrown as a warning, when an attempt is made to call operator int() before any operators >>() are called. That is, before anything was read from the stream, and yet, operator int() is called, which does not make any sense, because the operator returns an "end-of-file" (eof) status of the stream, after something is supposed to be read from the stream. The difference in semantic between operator int() and eof() is that eof() should be called before anything is read from the stream, and operator int() should be called after something is read from the stream. In other words, operator int() returns a deferred end-of-file status of the stream, for example:

      while(s>>f1>>f2){ // operator int() gets called here AFTER
          // two operators >>() get called in the loop condition     

     versus the typical use of otl_stream::eof():

      while(!s.eof()){ // eof() gets called BEFORE something gets read from the stream
        s>>f1>>f2; // operators() >> get called AFTER the eof() status was checked


  • Action: Change the logic of the program so that operator int() would be called only after some calls to operators >>()  have already been made, or so that operator int() would not be called at all. Also, it is a good idea to use otl_stream::eof() instead of implicit calls to operator int().
Code=32020: otl_stream_read_iterator: otl_stream is not open
  • CauseThe stream the iterator is attaching to is not open .
     
  • Action: OTL stream read iterator cannot be attached to a stream that was not opened yet. Make sure that the program logic is correct, and it does not try to attact to a closed stream.
Code=32021: otl_stream_read_iteratorPL/SQL table and 'refcur' parameters are not supported
  • Cause: Specified features are not supported.
     
  • Action:  If you need to use "refcurs" or PL/SQL tables, use the OTL stream interface. 
Code=32022: otl_stream_read_iterator: otl_stream cannot be described
  • Causeotl_stream_read_iterator (in attach() or in describe()) calls otl_stream::describe_out_vars() under the covers. When describe_out_vars() returns a 0 pointer back to the caller function, it normally means that the underlying stream cannot desribe its output structure. Typically, this happens in the case of a stored procedure returning an implcit result set (ODBC, DB2-CLI), or a stored procedure that returns a referenced cursor (Oracle).
     
  • Action: The stream output structure can be normally described after the execution of the underlying stored procedure. Therefore, the OTL stream read iterator should be attached to the stream after the execution of the stored procedure. Change your code accordingly.
Code=32023: otl_stream_read_iterator: position is out of range
  • CauseOTL stream read iterator template class provides a JDBC-like getter interface, which identifies output variables by their relative positions: 1,2,3,... This exception gets thrown when the specified "pos" parameter (in get() functions or in is_null() function) is out of range.
     
  • Action: Make sure that the specified pos is within the range. The whole set of output variables of the underlying stream can be describe by calling otl_stream_read_iterator.htm::describe().
Code=32024: otl_stream_read_iterator: incompatible types in get()
  • CauseThe data type of a variable used in the current get() operation is not compatible with the declared stream format. 
  • Action: Make sure the data types are compatible.

Code=32025: otl_stream::operator int() is not supported in the LOB stream mode
  • Cause:  operator int() is not supported in the LOB stream mode. 
  • Action: An attempt was made to call operator int() in the LOB stream mode.

Code=32026: otl_stream_read_iterator: get(otl_lob_stream*&) function can only be used if otl_stream::set_lob_stream_mode(true) had been called before the iterator was attached to the stream
  • Cause:  otl_stream_read_iterator can only be used when the underlying otl_stream is in te LOB stream mode.. 
  • Action: Set the underlying stream to the LOB stream mode.
Code=32027: otl_stream_read_iterator: : variable name is not recognized 
  • Cause:  OTL stream read iterator template class provides a JDBC-like getter interface, which identifies output columns / variables by their names This exception gets thrown when the specified "var_name" parameter (in get() functions or in is_null() function) is not recongnized.
     
  • Action: Make sure that the specified name is among the output columns / variables. The whole set of output variables of the underlying stream can be described by calling otl_stream_read_iterator.htm::describe().
Code=32028: Unsupported column data type
  • Cause:  OTL stream finds a column in a SELECT statement / stored procedure call (ODBC, DB2 CLI) / reference cursor (Oracle) of an unsupported data type. For example, OTL does not support Oracle Objects.
     
  • Action: Make sure that the data types of the all columns of your SELECT statement are supported by OTL. otl_exception::var_info contains info on which column exactly has an unsopprted data type.
Code=32029: RAW value cannot be read with otl_lob_stream, use otl_long_string instead
Code=32030: otl_stream is already open
  • Cause:  OTL stream was already open when otl_stream::open() was called on the same stream.
     
  • Action: Before opening a stream, make sure that it's not already open by calling otl_stream::good() on the stream:

       if(!my_str.good()){
         // stream is not open

Code=32031: otl_connect is already connected
  • Cause:  OTL connect object was already connected to the database when otl_connect::rlogon() was called on the same object.
     
  • Action: Before connecting an otl_connect object to the database, make sure that the object is not already connected:

       if(!my_connect.connected){
         // connect object is not connected 

Code=32032: SELECT otl_stream buffer size for TimesTen should be in [0..128] range
  • Cause:  OTL stream uses the TimesTen TT_PREFETCH_COUNT under #define OTL_ODBC_TIMESTEN_WIN, and OTL_ODBC_TIMESTEN_UNIX, which has the range of [0..128].
     
  • Action: The OTL stream size buffer needs to be changed to a value in the range of [0..128].

Code=32033: otl_connect object needs to be connected to DB before using otl_subscriber
  • Cause:  OTL connect object needs to be connected to the database, before otl_subscriber objects can be used with the otl_connect object..
     
  • Action: Connect your otl_connect object to the database, and then try to use your otl_subscriber objects with the otl_connect object.

Code=32034: otl_stream buffer size should be 1 when refcur or plsql table is used
  • Cause:  OTL stream uses a refcur bind variable (in a combination with  otl_refcur_stream), or PL/SQL tables, and the stream buffer size is larger than 1.
     
  • Action: Set the OTL stream buffer size to 1 and try again.

Code=32035: END-OF-ROW check failed
  • Cause:  otl_stream::check_end_of_row() was called to check the "end-of-row" condition. The condition was not met, and the function threw this exception. The "end-of-row" check addresses the "row-tearing" problem in a SELECT statement, for example:

    otl_stream sql(10,"select a, b from some_table",db); // only TWO columns

    while(!sql.eof()){
        int a, b, c;
        sql>>a>>b>>c; // this causes "row-tearing"
        // ...
    }

    The way OTL uses the C++ stream idiom is said to be unsafe, and that it potentially could cause a "row-tearing" problem, which could be very hard to troubleshoot and maintain. The check_end_of_row() function addresses the problem, so, in order to make sure the code is safe and maintainable, here's how the example above can be rewritten:

    otl_stream sql(10,"select a, b from some_table",db); // only TWO columns

    while (!sql.eof()){
        int a, b;
        sql>>a>>b;
        sql.check_end_of_row();

        // ...
    }

    or this way:

    otl_stream sql(10,"select a, b from some_table",db); // only TWO columns

    while (!sql.eof()){
        int a, b;
        sql>>a>>b>>endr;
        // ...
    }

    In case if the number of columns in the SELECT statement changes, and the actual loop is not changed, the check_end_of_row() function (or its alternative operator>>() form) will throw this exception.

    Besides the row-tearing problem in SELECT statements, this OTL defined exception also addresses a similar "row-tearing" in INSERT / UPDATE /DELETE statements, or in calls to stored procedures / anonymous PL/SQL blocks, for example:

    otl_stream sql(10,"INSERT INTO test_tab VALUES(:f1<int>,:f2<int>)",db); // only TWO column
    int f1, f2;
    ...
    sql<<f1<<f2<<endr;
    sql<<f1<<f2;
    sql<<f2<<endr;

    As table layout, and code change over time,  "end-of-row" check may play more important role in keeping the code base in good shape, and reduce code rot.
     
  • Action: Modify your code so that the "end-of-row" condition is met at the end of reading each row in your SELECT statement, and try it again.
Code=32036: otl_connect is not connected to the database
  • Cause:  #define OTL_STREAM_THROWS_NOT_CONNECTED_TO_DATABASE_EXCEPTION was enabled, OTL stream did the otl_connect-not-connected-to-database check (if(!otl_connect::connected)), and the check returned true.
     
  • Action: Make sure that the otl_connect object that is passed into the otl_stream open() call was connected to the database.

Code=32037: SQL Statement has a white space in bind variable declaration
  • Cause:  White spaces are not allowed in OTL bind variable declarations.
     
  • Action: Fix the white spaces and try again.


Code=32038: otl_long_unicode_string should be used with strings when OTL_UNICODE is enabled, and otl_long_string should be use with strings when OTL_UNICODE is not enabled

  • Cause:  a variable of the otl_long_string class when OTL_UNICODE was enabled with VARCHAR / NVARCHAR / NTEXT / CLOB / NCLOB / etc column types instead of otl_long_unicode_string. Or otl_long_unicode_string was used whenOTL_UNICODE was not enabled.
     
  • Action: Use the appropriate "OTL long string" class and try again.


Code=32039: otl_long_string should be used with nonstrings when OTL_UNICODE is enabled

  • Cause:  a variable of the otl_long_unicode_string class when OTL_UNICODE was enabled with RAW / VARBINARY / LONG / VARBINARY(MAX) / etc. column types.
     
  • Action: Use the appropriate "OTL long string" class and try again.

Code=32040: This type of otl_stream can only have input variables

  • Cause:  This exception is raised when the stream is opening a call to a stored procedure that returns an implicit result set, and the stream finds output, or input/output parameters in the call.
     
  • Action: Fix the stored procedure call (use only input parameters), and try again.


Code=32041: Invalid stream buffer size (<=0)

  • Cause:  This exception is raised when the stream buffer size is <= 0.
     
  • Action: The stream buffer size should be a positive integer. Fix the buffer size and try again.


Code=32042otl_lob_stream can't be used as an input parameter with a SELECT statement 
 or a stored procedure that returns an implicit result set

  • Cause:  This exception is raised when the stream is used with a SELECT statement, or a stored procedure that returns an implicit result set (DB2 CLI, or ODBC).
     
  • Action: Fix the code and try again.


Code=32043: otl_stream::operator>>(XXX) has been called when EOF was already reached

  • Cause:  This exception is raised when the otl_stream::eof() returns 1/true and an attempt to call otl_stream::operator>>(XXX) is being made. This exception can only raised when #define OTL_PARANOID_EOF is enabled.
     
  • Action: Correct the program logic and try again.

Code=32043: otl_stream::operator>>(XXX) has been called when EOF was already reached

  • Cause:  This exception is raised when the otl_stream::eof() returns 1/true and an attempt to call otl_stream::operator>>(XXX) is being made. This exception can only raised when #define OTL_PARANOID_EOF is enabled.
     
  • Action: Correct the program logic and try again.

Code=32044: Bind variable declaration is missing a terminator: > or */

  • Cause:  Bind variable declaration is not complete: a terminator token of > or */ is missing.
     
  • Action: Correct the bind variable declaration and try again.



Prev  Contents Go Home


Copyright © 1996-2014, Sergei Kuchin, email: skuchin@gmail.comskuchin@gmail.com Last Updated: 1/5/014..

Permission to use, copy, modify and redistribute this document for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值