Welcome Guest, Not a member yet? Register   Sign In
Oracle Nextval issue
#1

[eluser]dignityandshame[/eluser]
I've got an interesting issue going on here when grabbing the nextval from a sequence in Oracle. The problem is that the nextval increments by 3 each time, not 1. The increment parameter is set to 1 in Oracle, and if I do the same select from the command line, it returns the nextval incremented by only 1. So, my question is, why and/or how is this being incremented by 3 when I run the query through CI?

Code:
$sql = "select testlog.schedule_seq.nextval from dual";
$query = $this->db->query($sql);
$row = $query->row();
echo $row->NEXTVAL;
#2

[eluser]jedd[/eluser]
Howdi, and welcome to the CI forums.

I know next to nothing about Oracle, but I'm assuming that nextval is meant to return one row?

It might be worth doing a num_rows() call in there, before you access the row, to make sure that you did in fact only get one row. $query->row() of course will work fine with multi-row results, it'll just blissfully return the first row only.
#3

[eluser]dignityandshame[/eluser]
It's only returning one row. That nextval query in Oracle is the equivalent of an auto_increment field in MySQL (since Oracle doesn't have an auto_increment feature :-S ). Somehow this query is being run 3 times. It's not inside any kind of loop or anything either.
#4

[eluser]jedd[/eluser]
Okay, the next thing I'd try (because it's easy) is to turn on the [url="http://ellislab.com/codeigniter/user-guide/general/profiling.html"]Profiling Library[/url] - which will report, on your browser, the exact database calls being made. This should give you a pointer as to whether it's a weirdness with the Oracle/CI interaction (we don't get many Oracle users around these 'ere parts) or at the other end. I'm guessing you can crank up some Oracle profiling tools to see if it's getting the same request three times?
#5

[eluser]dignityandshame[/eluser]
Does it need to be placed anywhere special within the controller? I'm not getting any output...

Code:
function index() {
    
        $this->output->enable_profiler(TRUE);
        $data['title'] = "Scheduler";
        $data['query'] = $this->approve_model->getDetails();
        $data['table'] = $this->approve_model->getPendingTable($data['query']);
        $this->load->view('approve_view',$data);
    }
#6

[eluser]jedd[/eluser]
No, anywhere should be okay. I normally put it in my constructor, just so I can easily comment / de-comment it during development.

Do you mean you get no output at all or just no profiler output - should be trailing at the end of your web page - there's quite a bit of it, so it's hard to miss I guess.
#7

[eluser]dignityandshame[/eluser]
Sorry, I should've been a little more specific. No profiler output. There is output on the page though.

I'll see if I can fire up something from the Oracle side tomorrow when I'm back at work to see how many queries are coming in.

I'm intrigued by this profiler though so I'd like to get it displaying properly if possible.
#8

[eluser]dignityandshame[/eluser]
Disregard. I got the profiler working. It's only running one "nextval" query so I'll check things out from the Oracle side tomorrow.
#9

[eluser]dignityandshame[/eluser]
Ok, I'd say this is definitely some sort of bug within CI. On the Oracle side, the query shows up like this:

Code:
select testlog.schedule_seq.nextval from dualselect testlog.schedule_seq.nextval from dualselect testlog.schedule_seq.nextval from dual

I wrote my own connection/query using the base oci php functions and the number only increments by 1 each time.
#10

[eluser]jedd[/eluser]
Well .. it's time to file that bug report. As I mentioned, we don't see a lot of Oracle users, and I guess the same goes for the EL guys.

You could try running the query twice - it'd be fascinating it you got a result of 4 incs rather than 6. Smile (I'm having a Joseph Heller flashback now.)

And you have stuck an echo "BOB SAYS HI" or similar in there, to really be sure that that code block only gets hit the once, right?




Theme © iAndrew 2016 - Forum software by © MyBB