Two problems with Oracle and sequences

Edi Weitz <[email protected]>
Newsgroups gmane.lisp.clsql.devel
Message-ID <[email protected]>
Hi Kevin!

This is with LWW 4.4.5 against an Oracle 10gR2 installation on Linux.
CLSQL is 3.2.1.

If I do

  (create-sequence 'foo)
  (set-sequence-position 'foo 1)

I'm thrown to the console because of the following error:

  ORA-04002: INCREMENT must be a non-zero integer

This is due to the SQL statement

  ALTER SEQUENCE FOO INCREMENT BY 0

which Oracle doesn't seem to like.

I think this can be changed by modifying the corresponding definition
in oracle-sql.lisp to be:

  (defmethod database-set-sequence-position (name position (database oracle-database))
    (without-interrupts
     (let* ((next (database-sequence-next name database))
            (incr (- position next)))
       (unless (zerop incr)
         (database-execute-command
          (format nil "ALTER SEQUENCE ~A INCREMENT BY ~D" name incr)
          database))
       (database-sequence-next name database)
       (database-execute-command
        (format nil "ALTER SEQUENCE ~A INCREMENT BY 1" name)
        database))))

The second one can be reproduced like this:

  (create-sequence 'foo42)
  (sequence-last 'foo42)

Now I'm in the ugly LW console again with the

  ORA-00911: invalid character

error from Oracle which is due to the SQL statement

  SELECT LAST_VALUE FROM _CLSQL_SEQ_FOO42

and Oracle not accepting identifiers starting with an underline.
Actually, I wonder why this intermediate table is there at all.
Shouldn't it be possible to implement CLSQL's sequence functions on
Oracle without such a table?

Cheers,
Edi.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.