From f21b18a2be8f64c13908723b0c0d8212683ae5b6 Mon Sep 17 00:00:00 2001
From: Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Date: Sat, 11 Oct 2008 10:23:03 +0000
Subject: [PATCH] next_id : merged Tony's changeset r9516 from 4.2 branch

---
 PLC/PostgreSQL.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/PLC/PostgreSQL.py b/PLC/PostgreSQL.py
index 4e056394..98ef727c 100644
--- a/PLC/PostgreSQL.py
+++ b/PLC/PostgreSQL.py
@@ -134,6 +134,15 @@ class PostgreSQL:
         cursor.close()
         return self.rowcount
 
+    def next_id(self, table_name, primary_key):
+	sequence = "%(table_name)s_%(primary_key)s_seq" % locals()	
+	sql = "SELECT nextval('%(sequence)s')" % locals()
+	rows = self.selectall(sql, hashref = False)
+	if rows: 
+	    return rows[0][0]
+		
+	return None 
+
     def last_insert_id(self, table_name, primary_key):
         if isinstance(self.lastrowid, int):
             sql = "SELECT %s FROM %s WHERE oid = %d" % \
-- 
2.47.0