databaseManager.getNextSequence() returns null

When using db identity sequences on Sybase 10 and Servoy 3.5.2,
I get null as result by doing:

var vTargetTable = forms[vTargetForm].controller.getTableName()
var vTargetServer = forms[vTargetForm].controller.getServerName()
var vTargetPKField = vTargetTable + '_id'
var vNextSequence = databaseManager.getNextSequence(vTargetServer, vTargetTable, vTargetPKField)

All variables are set correcty, I only don’t get the next sequence.

Sybase 10 db identity sequences
Servoy Developer
Version 3.5.2_04-build 515
Java version 1.6.0_02-b06 (Windows XP)

Hi karel,

Does it work when you put the values hard in the getNextSequence() function ?

Hi Karel,

I just did a quick test using your code on Sybase 9 using Servoy Sequence which did return me the next sequence

I then tried it using MySQL and a DB identity (the column is defined as PK with auto increment - the database as INNODB) and had null returned !

Cheers
Harry

Servoy Developer
Version 3.5.2-build 515
Java version 1.5.0_07-87 (Mac OS X)
MySQL 5.0.27

Harry Catharell:
Hi Karel,

I just did a quick test using your code on Sybase 9 using Servoy Sequence which did return me the next sequence

I then tried it using MySQL and a DB identity (the column is defined as PK with auto increment - the database as INNODB) and had null returned !

Hi Harry,

Agree with your testresult. It seems that databaseManager.getNextSequence() does not return the next db sequence when using DB identity, but only returning the next sequence when using Servoy sequences.

It looks like something Servoy should fix.

In my case I don’t need the next sequence, but I want to use the record locking that Servoy does with this method in the background, to prevent setting false or not-unique custom sequences in our solution.

ROCLASI:
Hi karel,
Does it work when you put the values hard in the getNextSequence() function ?

Hey Robert, nope, same issue…

Hi Karel,

I’d go along with your conclusion.

There is nothing in docs to suggest that it only works on Servoy sequences AND as there is a ‘sync with db’ option in auto enter options I would have assumed that the getNextSequence could trigger a similar request to the DB.

On reflection though there is nothing to point the getNextSequence function to the correct source of either Servoy or DB Identity so is it that it cannot know which way to go other than to Servoy as the default !?

Cheers
Harry

Hi guys,

the getNextSequence has (IMHO ;-) ) nothing to do with your db or servoy sequences. It is build to hold your ‘own’ table with your ‘own’ sequences. (for instances for your invoicenumbers projectsnumbersetc…etc…)
the function uses the same locking technique that servoy uses, for preventing multiple sequnces with the same number.

Hope this helps

HJK:
Hi guys,

the getNextSequence has (IMHO ;-) ) nothing to do with your db or servoy sequences. It is build to hold your ‘own’ table with your ‘own’ sequences. (for instances for your invoicenumbers projectsnumbersetc…etc…)
the function uses the same locking technique that servoy uses, for preventing multiple sequnces with the same number.

Hope this helps

Thanks Harjo,
This clearifies a lot… If this is the case, I think the function should be called
getNextCustomSequence(), otherwise it’s confusing with db or Servoy sequence functionality.

Hi,

The getNextSequence function returns the next value that would be generated for the specified column.
This works for servoy-sequences and for db-sequences because you can ask the system (either servoy or the db) to generate the next value for you.

For DB identity columns it works differently, the next value is generated by the DB, but only when you insert a new row.
After the insert (which does not supply a value for the pk) a separate (different for each db type) query is fired to fetch the value generated in the insert statement.

So getNextSequence does not work on a db identity column because there is no data to insert.

Rob