If you use views to insert/update data, better use the well known routine, will keep you out of trouble, believe me. I use something like WorkstationId+sys(2015) as primary key (default value for views), isn't as small as an integer key, but I can work disconnected if I want and I don't need to search/lock the PK's table.
Have a nice day
>Hello, everyone
>
>I am trying to use this new kind of field. Works fine, unless I use a view to update the table and I need to know the value, to use it in a secondary table, as FK. In SQL Server we have @@Identity, which returns the last integer value inserted, but I have absolutely no idea how to handle this in VFP. According to the help, I need to do a REQUERY to see the new value.
>
>Are they kidding me or do I miss something here? First, the whole thing is in a transaction - can't REQUERY() in transactions. Second, to REQUERY() I need a parameter, which, in this case, is exactly the value I need to know - the Autoinc PK. Deadlock. If I don't use any parameter, I'll get all the records, and even me I'm not stupid enough to do such thing. Another deadlock.
>
>There is another way: SELECT * FROM table WHERE field1 = value1 AND field2 = value2 ... .... ........, where "values" are the brand new inserted values. First - a lot of work just to get an integer. Second, I'm not 100% sure I'll get one single record - there could exist duplicate records, only their PK is different. Another deadlock.
>
>Nah. I'd better stick using the Tastrade way.
>
>What do you do in such cases, guys? I can't believe I'm the first one having this problem....
>
>Thank you
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only