If there was one thing I really disliked about SOCI and had to change,
it was getting silly meaningless context-less errors like bad_cast.

I had to fix that to get it to try to work, e.g. convert different
integer types, and then provide context if it still failed.

Please consider making your exceptions meaningful, so if there is an
error there, you know how to fix it.


On Tue, Jun 11, 2013 at 8:57 AM, Lalit Bhasin <[email protected]> wrote:
> Hi Guys,
>
> 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 ??
>
> }
> *************************
>
> 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.
>
> Thanks,
> Lalit
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> 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
>

------------------------------------------------------------------------------
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