summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2017-01-30 14:03:42 +0100
committerTim Graham <timograham@gmail.com>2017-01-30 08:03:42 -0500
commit89501d9298494d732f56cf577e70d4203f45467b (patch)
tree86c87cd5b95d31b8c200d917c6672e9ff38e47e2
parent068cd6036651c7564dd3e465fbea458b75d7244a (diff)
Fixed #27789 -- Simplified query for sequence value on Oracle.
-rw-r--r--django/db/backends/oracle/operations.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/django/db/backends/oracle/operations.py b/django/db/backends/oracle/operations.py
index 5a182d59e9..f8fee3bd3d 100644
--- a/django/db/backends/oracle/operations.py
+++ b/django/db/backends/oracle/operations.py
@@ -34,7 +34,7 @@ BEGIN
SELECT NVL(last_number - cache_size, 0) INTO seq_value FROM user_sequences
WHERE sequence_name = '%(sequence)s';
WHILE table_value > seq_value LOOP
- SELECT "%(sequence)s".nextval INTO seq_value FROM dual;
+ seq_value := "%(sequence)s".nextval;
END LOOP;
END;
/"""
@@ -69,8 +69,7 @@ BEFORE INSERT ON %(tbl_name)s
FOR EACH ROW
WHEN (new.%(col_name)s IS NULL)
BEGIN
- SELECT "%(sq_name)s".nextval
- INTO :new.%(col_name)s FROM dual;
+ :new.%(col_name)s := "%(sq_name)s".nextval;
END;
/""" % args
return sequence_sql, trigger_sql
@@ -258,7 +257,7 @@ WHEN (new.%(col_name)s IS NULL)
def last_insert_id(self, cursor, table_name, pk_name):
sq_name = self._get_sequence_name(table_name)
- cursor.execute('SELECT "%s".currval FROM dual' % sq_name)
+ cursor.execute('"%s".currval' % sq_name)
return cursor.fetchone()[0]
def lookup_cast(self, lookup_type, internal_type=None):