Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Possible SqlOption Problem [Solved]
Possible SqlOption Problem [Solved] [message #4401] Fri, 04 August 2006 23:58 Go to next message
rbmatt is currently offline  rbmatt
Messages: 90
Registered: July 2006
Location: Tennesse, USA
Member

My application is currently using two SqlOption checkboxes which are stored into the database (SqLite or MySQL). I've been having some problems though when retrieving the values.
The following code crashes with an assert:
if(list.CListView.Get(SERVICE))

Assertion failed in C:\uppsrc\Core/Value.h, line 417
dynamic_cast<const RichValueRep *>(p)

It should be returning int(0,1) bool(true,false) or NULL. It looks like it's returning a RichValue? I don't know enough about U++ yet to track it down.
BTW Mirek, this is probably the same thing that made me put in an AsString.

[Updated on: Sat, 05 August 2006 07:24]

Report message to a moderator

Re: Possible SqlOption Problem [message #4403 is a reply to message #4401] Sat, 05 August 2006 06:54 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I am sorry, it is really not very intuitive, but to conserve the space in DB, scheme BOOL is represented by string with values "0" and "1". That is also the difference between Option and SqlOption (regular Option uses bool).

Therefore you should be using

if((String)list.CListView.Get(SERVICE) == "1")

Mirek
Re: Possible SqlOption Problem [message #4405 is a reply to message #4403] Sat, 05 August 2006 07:24 Go to previous messageGo to next message
rbmatt is currently offline  rbmatt
Messages: 90
Registered: July 2006
Location: Tennesse, USA
Member

Makes sense. Thanks.
Re: Possible SqlOption Problem [message #22783 is a reply to message #4403] Fri, 14 August 2009 21:39 Go to previous messageGo to next message
marroyo is currently offline  marroyo
Messages: 8
Registered: August 2009
Location: Argentina
Promising Member
I've same problem when using a SqlOption in a PostgreSQL application. The column is a bool type PGAdmin III show column values as true or false.

Assertion failed in C:\uppsrc\Core/Value.h, line 417
dynamic_cast<const RichValueRep *>(p)


Assertion fails on sql_array.Query();

Using Option doesn't work because it return a int and then insert fails.

Any help?
Re: Possible SqlOption Problem [message #22792 is a reply to message #22783] Sun, 16 August 2009 23:58 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
marroyo wrote on Fri, 14 August 2009 15:39

I've same problem when using a SqlOption in a PostgreSQL application. The column is a bool type PGAdmin III show column values as true or false.

Assertion failed in C:\uppsrc\Core/Value.h, line 417
dynamic_cast<const RichValueRep *>(p)


Assertion fails on sql_array.Query();

Using Option doesn't work because it return a int and then insert fails.

Any help?


Well, I do not really have enough info.

Anyway, SqlOption provides String - because some DB do not support "bool" type.

If the "bool" in DB is real bool, I believe normal Option should work fine.

Mirek
Re: Possible SqlOption Problem [message #22799 is a reply to message #22792] Mon, 17 August 2009 15:39 Go to previous messageGo to next message
marroyo is currently offline  marroyo
Messages: 8
Registered: August 2009
Location: Argentina
Promising Member
Hi Mirek. I will be more explicit now.
I have a PostgreSQL table SOCIO with a activo (active) boolean field.

I've defined a window with a SqlArray object.

SqlArray show's me the boolean column as value 1.

I want edit fields, so I add a column to SqlArray by doing

socios_array.AddColumn(ACTIVO, "Activo").Edit(activo);

If I declare activo of SqlOption type, when I try to do socios_array.Query(), I get the following assertion failure:

Assertion failed in C:\uppsrc\Core/Value.h, line 417
dynamic_cast<const RichValueRep *>(p)


If I declare activo as Option type, I can't edit (or insert) rows because the SQL statement generated is

insert into SOCIO(OBJID, RAZON_SOCIAL, ACTIVO, CATEG_IVA) values (801, 'MARCELO', 1, 'C')

You can see that ACTIVO column value is an integer (not a boolean), getting a database error from PostgreSQL.

I could fix it doing a Convert from Option, but I think it is the goal of SqlOption.

Thank you.
Re: Possible SqlOption Problem [message #22803 is a reply to message #22799] Mon, 17 August 2009 20:18 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Hm, so does it mean it does not accept 1 0 as boolean values?

That is pretty bad... In that case we might have to develop a special type for this purpose...

Mirek

Re: Possible SqlOption Problem [message #22814 is a reply to message #22803] Tue, 18 August 2009 20:25 Go to previous messageGo to next message
marroyo is currently offline  marroyo
Messages: 8
Registered: August 2009
Location: Argentina
Promising Member
PostgreSQL doesn't accept 0, 1 as boolean values.

Extract from PostgreSQL manual:

Valid literal values for the "true" state are:

TRUE
't'
'true'
'y'
'yes'
'1'

For the "false" state, the following values can be used:

FALSE
'f'
'false'
'n'
'no'
'0'

For now, I've to define a Convert for Option.

Thank you, Mirek.
Re: Possible SqlOption Problem [message #22839 is a reply to message #22814] Fri, 21 August 2009 14:27 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
marroyo wrote on Tue, 18 August 2009 14:25

PostgreSQL doesn't accept 0, 1 as boolean values.

Extract from PostgreSQL manual:

Valid literal values for the "true" state are:

TRUE
't'
'true'
'y'
'yes'
'1'

For the "false" state, the following values can be used:

FALSE
'f'
'false'
'n'
'no'
'0'

For now, I've to define a Convert for Option.

Thank you, Mirek.


Hm, now looking at THIS, maybe the correct solution would be to convert Postgre bool (in to "0" or "1" (now it is getting converted to numeric value). In that case, SqlOption would still be working and Insert would accept "0" "1" values just fine. What do you think?

Something like:

void PostgreSQLConnection::GetColumn(int i, Ref f) const
{
.....
		case BOOL_V:
			f.SetValue(*s == 't' ? true : false);
			break;


to

void PostgreSQLConnection::GetColumn(int i, Ref f) const
{
.....
		case BOOL_V:
			f.SetValue(*s == 't' ? "1" : "0");
			break;


[Updated on: Fri, 21 August 2009 14:27]

Report message to a moderator

Re: Possible SqlOption Problem [message #22845 is a reply to message #22839] Fri, 21 August 2009 19:12 Go to previous messageGo to next message
marroyo is currently offline  marroyo
Messages: 8
Registered: August 2009
Location: Argentina
Promising Member
I think that it should be the best solution. I'll try it and let you know.

Thanks again Mirek, very much.
Re: Possible SqlOption Problem [message #22907 is a reply to message #22845] Wed, 26 August 2009 23:37 Go to previous messageGo to next message
marroyo is currently offline  marroyo
Messages: 8
Registered: August 2009
Location: Argentina
Promising Member
Mirek, it works!

I think PostgreSQL users will have the same problem. It should be a permanent change in the PostgreSQL package.

Thanks, again.
Re: Possible SqlOption Problem [message #22912 is a reply to message #22907] Fri, 28 August 2009 09:54 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
marroyo wrote on Wed, 26 August 2009 17:37

Mirek, it works!

I think PostgreSQL users will have the same problem. It should be a permanent change in the PostgreSQL package.

Thanks, again.



It is now Smile

Mirek
Previous Topic: MSSQL binary data
Next Topic: [sql] Select embeded in join
Goto Forum:
  


Current Time: Fri Mar 29 15:35:24 CET 2024

Total time taken to generate the page: 0.01047 seconds