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 » SqlArray Insert
SqlArray Insert [message #4139] Tue, 25 July 2006 02:31 Go to next message
rbmatt is currently offline  rbmatt
Messages: 90
Registered: July 2006
Location: Tennesse, USA
Member

When my SqlArray inserts a value, it uses NULL for the ID so the DB generates an autonumber. But then if I join something else, it does not work because there is no primary key to search by (it is null in the array, but not in the DB).
Ideally, it would find the last_insert_id and set the value to the array. I couldn't get that to work, though.
I could requery the DB on insert, but I would prefer not to b/c I will have a large number of entries.
What do you suggest?
Re: SqlArray Insert [message #4146 is a reply to message #4139] Tue, 25 July 2006 15:48 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
rbmatt wrote on Mon, 24 July 2006 20:31

When my SqlArray inserts a value, it uses NULL for the ID so the DB generates an autonumber. But then if I join something else, it does not work because there is no primary key to search by (it is null in the array, but not in the DB).
Ideally, it would find the last_insert_id and set the value to the array. I couldn't get that to work, though.
I could requery the DB on insert, but I would prefer not to b/c I will have a large number of entries.
What do you suggest?


Actually, I was afraid of this moment Smile

I know for some time now that the Sql package needs fixing to find a way how to return "autonumbers".

Just to explain things: the original database it was developed for is Oracle, which instead of this feature has sequences are separate entitity.

OK, I will do that ASAP. Meanwhile, please use "InsertValue" to assign some of yours "autonumbers".

Mirek
Re: SqlArray Insert [message #4151 is a reply to message #4146] Tue, 25 July 2006 17:14 Go to previous messageGo to next message
rbmatt is currently offline  rbmatt
Messages: 90
Registered: July 2006
Location: Tennesse, USA
Member

luzr wrote on Tue, 25 July 2006 09:48

OK, I will do that ASAP. Meanwhile, please use "InsertValue" to assign some of yours "autonumbers".

Thanks so much, and take your time. While I'm still in testing phase it is OK for me to just requery the DB b/c I'm just using a data subset.
Also, any reason why UpdateRow() is protected and not public? Is there any public interface to get this functionality? (The only way I see is to SetCursor() to a different row and then set it back).
Re: SqlArray Insert [message #4153 is a reply to message #4151] Tue, 25 July 2006 18:27 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
"Accept".

Note that it is virtual method defined in Ctrl and has meaning "finish work and accept values" (returns false if fails).

Mirek

[Updated on: Tue, 25 July 2006 18:27]

Report message to a moderator

Re: SqlArray Insert [message #4161 is a reply to message #4139] Tue, 25 July 2006 23:20 Go to previous messageGo to next message
rbmatt is currently offline  rbmatt
Messages: 90
Registered: July 2006
Location: Tennesse, USA
Member

Great, thanks. Works like a charm.

Do you think SqlArray::DoRemove() should return a bool of if the record was deleted?
The reason I ask is I have a joined table. If I delete a record, I also want to delete everything in the joined table with that foreign key. SqlArray::DoRemove() throws up a PromptOKCancel so I don't want to put one in there on my own. So now I don't know if the user clicked Ok or Cancel.
Re: SqlArray Insert [message #4166 is a reply to message #4161] Wed, 26 July 2006 13:19 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Actually, "built-in" deleting capability is more or less designed for less-complicated cases.

In fact, in most of my current apps, I do like more to implement my own separate "delete", "insert" and "edit", going through additional dialog (not delete of course), then requery SqlArrays (or even ArrayCtrls) after operation done.

Mirek
Previous Topic: Fields
Next Topic: 607-Dev3 Errors (worked previously) [SOLVED]
Goto Forum:
  


Current Time: Sun Apr 28 22:33:30 CEST 2024

Total time taken to generate the page: 0.05208 seconds