Home » U++ Library support » U++ SQL » Possible SqlOption Problem [Solved]
Possible SqlOption Problem [Solved] [message #4401] |
Fri, 04 August 2006 23:58  |
|
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 #22799 is a reply to message #22792] |
Mon, 17 August 2009 15:39   |
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 #22839 is a reply to message #22814] |
Fri, 21 August 2009 14:27   |
 |
mirek
Messages: 14255 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
|
|
|
|
|
|
Goto Forum:
Current Time: Mon Apr 28 08:53:15 CEST 2025
Total time taken to generate the page: 0.01270 seconds
|