Skip to content

Commit

Permalink
Fixed #27789 -- Simplified query for sequence value on Oracle.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixxm authored and timgraham committed Jan 30, 2017
1 parent 068cd60 commit 89501d9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions django/db/backends/oracle/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DatabaseOperations(BaseDatabaseOperations):
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;
/"""
Expand Down Expand Up @@ -69,8 +69,7 @@ def autoinc_sql(self, table, column):
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
Expand Down Expand Up @@ -258,7 +257,7 @@ def last_executed_query(self, cursor, sql, params):

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):
Expand Down

0 comments on commit 89501d9

Please sign in to comment.