Thanks. Good that this is known issue, and would be worked upon in future.
I think I can live with fixing it with some trial and errors .

/ Lalit


________________________________
 From: Mateusz Loskot <[email protected]>
To: Lalit Bhasin <[email protected]>; SOCI general discussion list 
<[email protected]> 
Sent: Tuesday, June 11, 2013 10:05 PM
Subject: Re: [soci-users] bad_cast error (oracle backend)
 

On 11 June 2013 08:57, Lalit Bhasin <[email protected]> wrote:
>
> Here is my test code to simulate the problem:
>
> *****************
> #include <soci/oracle/soci-oracle.h>
> #include<soci/soci.h>
> #include<iostream>
>
> main()
>
> {
>     soci::session sql( soci::oracle, "service=XE user=scott password=tiger"
> );
>     soci::rowset<soci::row> rs = (
>         sql.prepare << "select data_length+0, data_length from "
>         << " user_tab_cols  where table_name = 'TABLE2' ");
>
>     soci::rowset<soci::row>::const_iterator it = rs.begin();
>     soci::row const & row = *it;
>     std::cout << "DATA_LENGTH + 0 = " << row.get<int>(0) <<std::endl;
> // no error here as expected
>     std::cout << "DATA_LENGTH = " << row.get<int>(1) <<std::endl;
> // this gives bad_cast error. Why ??
>
> }
> *************************

I'm afraid you've hit the known nasty deficiency in SOCI integer types:

https://github.com/SOCI/soci/issues/90

> Now when  running this executable:
>
> sqlplus> create table table2 ( a number);
> sqlplus> exit
>
> [ubuntu_host]$ ./a.out
> DATA_LENGTH + 0 = 22
> terminate called after throwing an instance of 'std::bad_cast'
>   what():  St8bad_cast
> Aborted
> [ubuntu_host]$
>
>
> Any idea why I am getting bad_cast error on accessing data_length column
> from user_tab_cols view, even though the column is of type number ? The only
> way to access this column is using data_length+0 in select query.

I presume, one type is signed the other unsigned, and that hits the wall
of quite unfortunately simplified integral conversions in SOCI, currently.

I'm slowly working (investigating) on getting it right
(https://github.com/SOCI/soci/wiki/RFC1), but I'm too much
multitasking and dealing with unexpected bugfix releases in
meantime.

The only solution I can suggest is to match the right type by some
trial and error.
I know, I'm sorry :(

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to