the only way to identify the details of a purchase is that unique number by a Sql sentence
Whilst there's nothing wrong with having a unique id number for every record in the detail table, I think here that what you are wanting to do is to be able to discern between the detail lines of a purchase. I have previously done this by having a "line number" field that is the position of that detail line on a printed representation of the purchase quote/order/invoice, and within the array that held the detail lines for display and editing.
But our editing was done in-memory, with the database only updated when the user clicked the "save" button... or abandoned when the user clicked the "cancel" button.
If you are editing the purchase "live" within the database, then this solution is probably better:
id ---> set this column to autoincrement
than you reimplementing a similar functionality. Happily, it doesn't particularly matter that the number is more unique than it needs to be, and you can still sort the detail lines by this field to ensure that duplicate printouts have the detail lines in the same order (auditors hate stuff where prints of the same document appear different).