如何从数据库获取下一个客户发票ID? [英] How to get Next Customer Invoice id from database ?

查看:84
本文介绍了如何从数据库获取下一个客户发票ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我每次提交订单时如何获得POS下一位客户的发票ID。我在SQL中有一个自动增量的字段名称ID。但它是在提交数据库时生成的,而我在前一个客户完成时需要POS上的发票ID。



提前谢谢



Jazaib

Hello all there,

How i can get an invoice id for my POS next Customer each time i submit my order. I have a field name ID in SQL that is auto increment. But it is generating on the time of submission of database while i need Invoice id on POS on completion of previous customer.

Thanks in advance

Jazaib

推荐答案

您无法在多用户系统中可靠地从数据库中获取下一个ID。



想一想。您有2个客户端同时进入数据库。每个都从表中获取下一个id。他们都试图向表格提交新发票。一个将工作,另一个将失败,因为ID已被使用。
You cannot reliably get the "next" id from the database in a multiuser system.

Think about it. You have 2 clients going to the database at the same time. Each gets the "next" id from the table. They both try to commit a new invoice to the table. One will work and the other will fail because the ID is already in use.


您可以在数据库中插入空白记录,然后使用该ID。如果他们取消了该事务,请从数据库中删除该记录。这是在多用户数据库中保留ID的唯一可靠方法。
You could insert a blank record in your database, then use that ID. If they cancel the transaction, delete the record from the database. That's really the only reliable way to reserve an ID in a database thats multi-user.


这篇关于如何从数据库获取下一个客户发票ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆