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 » Trouble Adding rows to SqlArray
Trouble Adding rows to SqlArray [message #20257] Thu, 05 March 2009 15:38 Go to next message
bianconejo is currently offline  bianconejo
Messages: 11
Registered: March 2009
Promising Member
Hi Guys,

First of all I'd like to thank you and underline your talent for this great environnement.

I'm using Upp for 1 month now and I like the way it is structured.

I've studied HomeBudget, PostgreSQL example and SQLCommander.

I'd like to know how to add a new row to a sqlarray linked to a form (via array.addctrl).

I've tried several methods like DoAppend, Add and SQL insert query, but when I refresh the array, the new data are missing.

Thanx for your reply and keep up the good work!

the table I attempt to add data to:
TABLE_(ORGANISATION)
   SERIAL_  (ORGANISATION_ID) PRIMARY_KEY
   STRING_  (ORGANISATION_NOM, 200) INDEX
   INT64_  	(ORGANISATION_TYPE) REFERENCES(TYPE_ORGANISATION.TYPE_ORGANISATION_ID)
   INT64_  	(ORGANISATION_PREFIXE) REFERENCES(PREFIXE_ORGANISATION.PREFIXE_ORGANISATION_ID)
   STRING_  (ORGANISATION_OBS, 200)
END_TABLE


the definition of the array links:
a_cache.SetSession(m_session);
[..]
	
a_cache.SetTable(ORGANISATION);
a_cache.AddKey(ORGANISATION_ID);
a_cache.AddColumn(ORGANISATION_NOM, "Entreprise");
a_cache.AddColumn(ORGANISATION_TYPE, "Type");
a_cache.AddColumn(ORGANISATION_PREFIXE, "PREFIXE");
a_cache.AddColumn(ORGANISATION_OBS, "Obs");
a_cache.SetOrderBy(ORGANISATION_ID);
	
a_cache.AddCtrl(ORGANISATION_NOM,e_entreprise);
a_cache.AddCtrl(ORGANISATION_TYPE,d_Type);
a_cache.AddCtrl(ORGANISATION_PREFIXE,d_Prefixe);
a_cache.AddCtrl(ORGANISATION_OBS,e_Obs);
Re: Trouble Adding rows to SqlArray [message #20261 is a reply to message #20257] Thu, 05 March 2009 19:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
IMO, 'StartInsert' is what you need in this case.

If you use 'Appending().Removing()' modifiers, you will have correspoing commands in context menu.

Mirek
Re: Trouble Adding rows to SqlArray [message #20270 is a reply to message #20257] Fri, 06 March 2009 10:56 Go to previous messageGo to next message
bianconejo is currently offline  bianconejo
Messages: 11
Registered: March 2009
Promising Member
thanks a lot Mirek !

I'll try this now !
Re: Trouble Adding rows to SqlArray [message #20272 is a reply to message #20257] Fri, 06 March 2009 12:54 Go to previous messageGo to next message
bianconejo is currently offline  bianconejo
Messages: 11
Registered: March 2009
Promising Member
I ve tried StartInsert but I had redundent fields in the generated sql insert statement (see joined file).

I think I'll drop temporarily SQL arrays and try a less integrated approach in order to get more comfortable with the containers.

Another thank you for your great work
Re: Trouble Adding rows to SqlArray [message #20279 is a reply to message #20272] Fri, 06 March 2009 18:11 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Ah, yes, I missed that in your code. Obviously, you can insert single column just once...

Anyway, U++ still has a way around. ArrayCtrl (and therefore SqlArray) columns and widgets are quite loosely coupled with "indicies" in row. Specifically, you can use two "entities" to point to single row "index".

Practically, you should use AddCtrlAt in your code where you want just single column with two "visuals":

a_cache.AddCtrlAt(ORGANISATION_NOM,e_entreprise);


Mirek
Re: Trouble Adding rows to SqlArray [message #20315 is a reply to message #20279] Mon, 09 March 2009 12:08 Go to previous messageGo to next message
bianconejo is currently offline  bianconejo
Messages: 11
Registered: March 2009
Promising Member
Hi Mirek

Thanks again !!!


I tried the AddCtrlAt / StartInsert all seem to run well :

* when invoking StartInsert a new line is appending at the end of my SqlArray

* Controls linked to the Array with AddCtrlAt seem to "insert" the new values in the new array line ...

...but, the key column is the only one to remain empty.

For now, Reading and Updating from the gui to the DataBase is OK but creating a new line in the DB is quite problematic...

I tried to alter the definition of the array with AppendingAuto and then AutoInsertId ( I thought it could have get a primary key for the new row) but I got a Sql Error (two ID insertion attempt).

Do you have an idea to get this SQL insertion running ?


Re: Trouble Adding rows to SqlArray [message #20316 is a reply to message #20315] Mon, 09 March 2009 13:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
bianconejo wrote on Mon, 09 March 2009 07:08

Hi Mirek

Thanks again !!!


I tried the AddCtrlAt / StartInsert all seem to run well :

* when invoking StartInsert a new line is appending at the end of my SqlArray

* Controls linked to the Array with AddCtrlAt seem to "insert" the new values in the new array line ...

...but, the key column is the only one to remain empty.

For now, Reading and Updating from the gui to the DataBase is OK but creating a new line in the DB is quite problematic...

I tried to alter the definition of the array with AppendingAuto and then AutoInsertId ( I thought it could have get a primary key for the new row) but I got a Sql Error (two ID insertion attempt).

Do you have an idea to get this SQL insertion running ?





Unfortunately, this depends on DB choosen. For PGSQL or Oracle, I recommend using sequence and use it with InsertValue.

Mirek
Re: Trouble Adding rows to SqlArray [message #20319 is a reply to message #20316] Tue, 10 March 2009 09:46 Go to previous message
bianconejo is currently offline  bianconejo
Messages: 11
Registered: March 2009
Promising Member
thanks Mirek

I'll go to Oracommon in order to understand sequences.

thanks for the hint
Previous Topic: Compacting an MS-Access db
Next Topic: PostgreSQL example does not save data to database
Goto Forum:
  


Current Time: Thu Mar 28 16:24:09 CET 2024

Total time taken to generate the page: 0.01304 seconds