LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to return Record ID from an SQL write operation

I am currently using LabWindows/CVI Version 6.0 and SQL Toolkit version 2.0.6 and was wondering if there is any way to return the Record ID of a record which has just been created similar to the @@SELECT command in VB? At the moment I am writing the record and then having to do several operations which are taking a long time to complete, i.e.
 
DBAllowFetchAnyDirection
DBActivateSQL (SELECT * from Table)
DBNumberOfRecords
DBDeactivateSQL
DBBeginMap
DBMapColumnToInt (Record ID)
DBActivateMap
DBFetchRandom (Last Record)
DBDeactivateMap
 
I need this Record ID to cross reference a second table which contains results information.
 
0 Kudos
Message 1 of 6
(5,590 Views)

Hi Kacout,

Having looked at your query, I am wondering whether you could possibly post your code so I can have a look at it? I'm not sure offhand whther there is such a method directly available, and I have a feeling that the long winded process you mentioned may be the only way. but I will happily have a look into this further for you.I would just be easier to have a look at your code so I can grasp more solidly the purpose of your program.

Best wishes
Rob L

NI Applications Engineer

UK & Ireland


It only takes a click to rate this message 😉
Message 2 of 6
(5,555 Views)
Thanks for getting back to me - can you please supply email address and I will send code to you.
0 Kudos
Message 3 of 6
(5,550 Views)

Hi Kacout,

If you are able to provide me a with an email address, I can send you an email which you will be able to reply on.

Best wishes
Rob L

NI Applications Engineer

UK & Ireland


It only takes a click to rate this message 😉
0 Kudos
Message 4 of 6
(5,543 Views)

Email address is kenneth.coutts@raytheon.co.uk.

Regards.

 

0 Kudos
Message 5 of 6
(5,542 Views)
Hi Kacout,

My apologies that I have not been in touch for a while, it's been a bit crazy here and I've been having significant problems installing the SQL toolkit for CVI. I am still in the process of looking for a specific SELECT command equivalent to that found in VB, and will let you know when I do. In the mean time, I have developed the code below which I'm wondering might be of use to you. not sure if the syntax is completely correct, but I think you might be able to use it.

DBActivateSQL(SELECT[RECORD ID]FromTable.*SortBy[RECORD ID]Descending)
DBFetchRandom(FirstRecord)

Not sure if this will greatly increase the speed of your operation ( I think the main thing slowing it down is activating the Table into memory) but let me know if this is of any use. I could be on completely the wrong track.

Best wishes, I will be back in touch ASAP.


Rob L

NI Applications Engineer

UK & Ireland


It only takes a click to rate this message 😉
0 Kudos
Message 6 of 6
(5,474 Views)