Getting the next value of a Oracle sequence

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting the next value of a Oracle sequence

galvao
Hi everyone.

So, I'm teaching a ZF2 101 course on a company that uses Oracle and for
some irrelevant reason doesn't want to create a pre-insert trigger to
call a sequence.
After some searching and poking on ZF's code, I've came up with this
example[1] for a solution for the "save" method (in particular lines 14
and 15).

It seems to make perfect sense, but for some reason, I get the "Trying
to get property of non-object", on line 84 of SequenceFeature, so it
seems that it's not recognizing $this->tableGateway.

Mind that:

 1. I'm using everything else directly from the Skeleton tutorial
    (including using ServiceManager to configure the table gateway)
 2. We've dealt with Oracle's upper and lower case issues.
 3. Every single other example on CRUD works, and even using a static id
    works as well, so it's not DB-related.

Can anyone shed some light on this? Am I doing wrong from the start and
there's a better/more recommended way to do it?

[1] - https://gist.github.com/galvao/037138322b642ab0b823

Cheers,

--
Er Galvão Abbott

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Getting the next value of a Oracle sequence

Enrico Zimuel-2
Hi Er Galvao,

if you want to use the SequenceFeature you should pass it in the
TableGateway constructor.
The third parameter of TableGateway construct() is a $feature object (that
is null by default).
You can also set the TableGateway object using the setTableGateway() method
of SequenceFeature.
Without one of these two options the $tableGateway property of
SequenceFeature will be empty.

Regards,
Enrico Zimuel


On Wed, Sep 30, 2015 at 2:10 AM, Er Galvao Abbott <[hidden email]>
wrote:

> Hi everyone.
>
> So, I'm teaching a ZF2 101 course on a company that uses Oracle and for
> some irrelevant reason doesn't want to create a pre-insert trigger to
> call a sequence.
> After some searching and poking on ZF's code, I've came up with this
> example[1] for a solution for the "save" method (in particular lines 14
> and 15).
>
> It seems to make perfect sense, but for some reason, I get the "Trying
> to get property of non-object", on line 84 of SequenceFeature, so it
> seems that it's not recognizing $this->tableGateway.
>
> Mind that:
>
>  1. I'm using everything else directly from the Skeleton tutorial
>     (including using ServiceManager to configure the table gateway)
>  2. We've dealt with Oracle's upper and lower case issues.
>  3. Every single other example on CRUD works, and even using a static id
>     works as well, so it's not DB-related.
>
> Can anyone shed some light on this? Am I doing wrong from the start and
> there's a better/more recommended way to do it?
>
> [1] - https://gist.github.com/galvao/037138322b642ab0b823
>
> Cheers,
>
> --
> Er Galvão Abbott
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>
>


--

Enrico Zimuel
Senior Software Engineer | [hidden email] Team           |
http://apigility.orgZend Framework Team      |
http://framework.zend.comZend Technologies Ltd.http://www.zend.com
Reply | Threaded
Open this post in threaded view
|

Re: Getting the next value of a Oracle sequence

galvao
Thank you, Enrico. That worked perfectly.

Er Galvão Abbott

On 09/30/2015 03:06 AM, Enrico Zimuel wrote:

> Hi Er Galvao,
>
> if you want to use the SequenceFeature you should pass it in the
> TableGateway constructor.
> The third parameter of TableGateway construct() is a $feature object (that
> is null by default).
> You can also set the TableGateway object using the setTableGateway() method
> of SequenceFeature.
> Without one of these two options the $tableGateway property of
> SequenceFeature will be empty.
>
> Regards,
> Enrico Zimuel
>
>
> On Wed, Sep 30, 2015 at 2:10 AM, Er Galvao Abbott <[hidden email]>
> wrote:
>
>> Hi everyone.
>>
>> So, I'm teaching a ZF2 101 course on a company that uses Oracle and for
>> some irrelevant reason doesn't want to create a pre-insert trigger to
>> call a sequence.
>> After some searching and poking on ZF's code, I've came up with this
>> example[1] for a solution for the "save" method (in particular lines 14
>> and 15).
>>
>> It seems to make perfect sense, but for some reason, I get the "Trying
>> to get property of non-object", on line 84 of SequenceFeature, so it
>> seems that it's not recognizing $this->tableGateway.
>>
>> Mind that:
>>
>>  1. I'm using everything else directly from the Skeleton tutorial
>>     (including using ServiceManager to configure the table gateway)
>>  2. We've dealt with Oracle's upper and lower case issues.
>>  3. Every single other example on CRUD works, and even using a static id
>>     works as well, so it's not DB-related.
>>
>> Can anyone shed some light on this? Am I doing wrong from the start and
>> there's a better/more recommended way to do it?
>>
>> [1] - https://gist.github.com/galvao/037138322b642ab0b823
>>
>> Cheers,
>>
>> --
>> Er Galvão Abbott
>>
>> --
>> List: [hidden email]
>> Info: http://framework.zend.com/archives
>> Unsubscribe: [hidden email]
>>
>>
>>
>


--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]