Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: How do I solve the OCIError: ORA-02289: sequence does not exist error?

I have a model named "Carrier." In my controller, when I do a Carrier.create(data), I get this error:

OCIError: ORA-02289: sequence does not exist: select carriers_seq.nextval id from dual

This is my code in my controller:

class CarriersController < ActionController::Base
    def index
        #stuff
    end

    def update
        @params["carriers"].each do |id, data|
            #data["id"]
            if Carrier.exists?(data["id"])
                carrier = Carrier.find(data["id"])
                carrier.update_attributes(data)
            else
                Carrier.create(data)
            end
        end
        redirect_to( :action => "index" )
    end
end

I've done some googling, and I found these two webpages about a solution:

http://niranjansarade.blogspot.com/2011/03/avoid-oracle-sequence-during.html

http://www.dixis.com/?p=127

Where should I be putting the code for the ActiveRecord? Should it be going in my model?

Is there another solution to my error?

like image 824
Di Zou Avatar asked Sep 02 '25 08:09

Di Zou


1 Answers

I don't know about ruby but it surely has been configured or programmed to use the database sequence carriers_seq. (A sequence is sort of a number generator)

How about creating this sequence in the database? try to execute the following statement in Oracle SQL*Plus:

create sequence CARRIERS_SEQ;
like image 124
HAL 9000 Avatar answered Sep 04 '25 22:09

HAL 9000