Powerbuilder ‘Gotcha’ – SQLServer OLE DB and Identity columns

Posted on Wednesday, March 2nd, 2011 at 8:20 pm in

So I get a new machine at work and I’m busy loading all my development tools on it as well as changing settings and all such stuff. SQL Server and Powerbuilder get installed and upgraded, connected to Source Control, and I run the application from within the IDE. Things are fine until I insert a new set of records and save – BAM! ‘column such-and-such does not allow NULLs’ blah, blah, blah…

A quick trip to the debugger shows that the parent record is being inserted fine, but when I call my function to get the Identity value of the item just inserted, I’m getting back a NULL value.

After digging around awhile my boss remembers something. You need to modify the pbodb11.5.ini file in the appropriate sections

[MS_SQLSERVER_SYNTAX]
GetIdentity='Select SCOPE_IDENTITY()'

This has been around since 2009, see link.

and

[Microsoft SQL Server]
ServerCursor='No'

From Sybase web site:

ServerCursor database parameter
When you use the OLE DB database interface with a Microsoft SQL Server database and retrieve data into a DataWindow, server-side cursors are used to support multiple command execution. If this has a negative impact on performance, try increasing the size of the Block database parameter to 500 or more, or adding the following line to the [Microsoft SQL Server] section in the PBODB initialization file to turn off server-side cursors:

ServerCursor = ‘NO’
The ServerCursor parameter can be used only in the PBODB initialization file.

You might also be interested in

Add your comment

Leave a Reply

Top