1. Chay Wesley
  2. Valentina Database ADK
  3. Donnerstag, Februar 18 2016, 01:41 AM
  4.  Abonnieren via E-Mail
Just getting started with Valentina, and I'm thinking about how to implement binary links among tables in an application, and I don't quite get how to do it safely using the SQL interface, if the database is in simultaneous use by multiple users. The examples I see tend to follow these steps:

1) Insert something into master table
2) Select Last_Rec_ID_Of_Table to get recid of record inserted in step 1.
3) Link record to reference tables using Link Record.

My concern is when another connection is also inserting into the database between my step 1 and 2, then Last_Rec_ID will actually return the recid of the record inserted by the other user, right? Or is Last_Rec_ID in someway isolated per connection / etc?

Perhaps wrapping the entire sequence of steps 1-3 inside a transaction the proper way to guarantee the desired behavior, which then makes me wonder if Valentina supports nested transactions... That would certainly reduce the complexity of my application logic.

Thanks in advance for any pointers.
Kommentar
There are no comments made yet.
Ruslan Zasukhin Akzeptierte Antwort
Hi Chay,

1) as far as I remember, Last_RecID() is not affected by other users.
This is implemented inside of Valentina Server. It stores for each client its last recID.

2) Note that you can send few commands at once to VServer separated by ;
This should improve speed in case you link just added records
Kommentar
There are no comments made yet.
Ivan Smahin Akzeptierte Antwort
Yes, each client operates with own set of last_recids for every table, so you should not bother of getting result affected by another client.
Kommentar
There are no comments made yet.
Scott Akzeptierte Antwort
One of the reasons why I switched to VDB for all my database requirements was the use of Binary Links and the API method.

I am not sure how you are connecting to your VDB but using the API method you don't have to worry about concurrent connections. In Xojo for instance:

dim insertedRecID as Integer
insertedRecID = myTable.addRecord()

This returns the actual RecID of the inserted record. Doesn't matter how many inserts are occurring at once from multiple users. Once you have this RecID, you can now establish your Binary Link(s) as many times as you need.

Here's what I do:

1) I make my initial insert using the API method and get back the RecID of the insert. (See above)
2) Make the subsequent insert to a child record(s) and get that RecID(s) back as well.
3) Repeat as many times as you need for other child records.

Then:

dim link as VLink
link = table.link("lnk_Tbl1_Tbl2";)
dim bLink as VBinaryLink
bLink = link.AsVBinaryLink

dim Recs(1) as Integer
Recs(0) = RecID1 (of first insert or your Parent Record)
Recs(1) = RecID2 (of second insert or child record)
(repeat as many child tables you have in your link)

blink.LinkRecords(Recs) <----- BOOOOM. All of your records are now linked.

How simple does that get???
Kommentar
There are no comments made yet.
  • Seite :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Categories

Announcements & News
  1. 0 subcategories
Valentina Studio
  1. 2 subcategories
Valentina Server
  1. 4 subcategories
Valentina Database ADK
  1. 0 subcategories
Valentina Reports ADK
  1. 0 subcategories
Other Discussions
  1. 0 subcategories
BETA Testing
  1. 0 subcategories
Education & Research
  1. 0 subcategories
Omegabundle
  1. 0 subcategories