|
|
Home » U++ Library support » U++ SQL » SqlArray and default value of some field
SqlArray and default value of some field [message #33350] |
Wed, 27 July 2011 08:44  |
 |
forlano
Messages: 1207 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
Hello,
This post is connected with this one
http://www.ultimatepp.org/forum/index.php?t=msg&th=6105& amp; amp; amp;start=0&
and to the test case "SqlArray2.zip" provided by Sergey. I start a new topic as it is not specific of DropList and I am having problem even with OptionButton.
I have a SqlArray in which there are columns with DropList previuosly populated with some data. What I want is to let appear some default value in DropList. This default value should go in the database in case the user NOT modify its content.
In the Sergey test case the DropList is correctly populated:
SQL * Select(SqlAll()).From(COUNTRY_T);
while(SQL.Fetch()) {
country.Add(SQL[0],SQL[1]);
}
and then initialized to some default value
When I insert a record the DropList seems lazy and does NOT show its supposed default and remains empty. If the user accept the row without to select an item the field remain empty.
I tried even
to wake up the lazy DropList but without success.
So I tried to modify the SCHEMA with the row
INT_ (COUNTRY) SQLDEFAULT(12)
where '12' is the key code of value 'Russia'. Again the droplist remain empty and the database column too after accepting the row.
It seems the SQLDEFAULT does not work in sqlite3... if I have understood what it is intend for.
Any hint about setting a default value in SqlArray with embedded Ctrl?
Thanks,
Luigi
[Updated on: Wed, 27 July 2011 08:50] Report message to a moderator
|
|
|
|
|
|
|
|
Re: SqlArray and default value of some field [message #33388 is a reply to message #33385] |
Sun, 31 July 2011 09:03   |
 |
mirek
Messages: 14257 Registered: November 2005
|
Ultimate Member |
|
|
forlano wrote on Sat, 30 July 2011 16:19 |
mirek wrote on Sat, 30 July 2011 19:04 |
forlano wrote on Wed, 27 July 2011 02:44 |
Any hint about setting a default value in SqlArray with embedded Ctrl?
|
ArrayCtrl::IdInfo::InsertValue / ArrayCtrl::Column::InsertValue.
Mirek
|
Thank you,
the line
master.AddColumn(COUNTRY,"Country").SetConvert(Single<CountryConvert >()).Edit(country).InsertValue(12);
solved all the problems at once.
However i still wonder what SQLDEFAULT is intended to, or if I misused it. I believed it should take care of the default value.
Anyway one correct solution is enough
|
It does - on database schema level!
Inserting row into SqlArray is not the same thing as inserting it to DB.
If you would have issued statement
SQL * Insert
and omit the value for which you have defined SQLDEFAULT, database would fill it for you.
However, SqlArray in default mode does not even do SQL Insert befero you send the row into DB by hitting Enter. So it has to have a different set of default values, defined at SqlArray (/ArrayCtrl) level...
Mirek
|
|
|
|
|
Goto Forum:
Current Time: Tue May 13 11:01:16 CEST 2025
Total time taken to generate the page: 0.04005 seconds
|
|
|