| Subject |
Re: creating unique key : usingprimair key and foreign key |
| From |
Alex Safian <noway@noway.com> |
| Date |
Mon, 08 Feb 2021 14:10:31 -0500 |
| Newsgroups |
dbase.getting-started |
Akshat Kapoor Wrote:
> I just tried to explain what Mervyn said, At times it is difficult to
> obtain the value You inserted.
>
> We never said that there could be duplicates.
>
> If we are using beginappend() then we can obtain the value just inserted
> but if we are using sql then there is no confirmation that the last row
> was inserted by you.
>
> Regards
> Akshat
Thanks Akshat -- I didn't understand that the issue was creating a new record with SQL. Yes, with INSERT the record is created and if there is an autoinc field there will be a unique number created. But what is the number and where is the record? As you and Mervyn say, in a multi-user environment the number is not known and the record is not necessarily the last one in the table. It's kind of like the problem of creating unique account numbers in VdB 5.x witiout using seqvalue -- the alternative of going to the bottom of the table to find the supposedly latest account number and adding one to it is not reliable for the same reason.
But with beginappend() once you save, you're sitting on the new record, and you can certainly know what the new autoinc number is.
As Ken and Robbie said, if you use INSERT in a web app you will have to do some work to try to find the right record.
|
|