{"id":723,"date":"2011-03-02T20:20:05","date_gmt":"2011-03-03T01:20:05","guid":{"rendered":"http:\/\/anvil-of-time.com\/wordpress\/?p=723"},"modified":"2021-03-10T19:31:27","modified_gmt":"2021-03-11T00:31:27","slug":"powerbuilder-gotcha-sqlserver-ole-db-and-identity-columns","status":"publish","type":"post","link":"https:\/\/anvil-of-time.com\/powerbuilder\/powerbuilder-gotcha-sqlserver-ole-db-and-identity-columns\/","title":{"rendered":"PowerBuilder &#8216;Gotcha&#8217; &#8211; SQLServer OLE DB and Identity columns"},"content":{"rendered":"<p>So I get a new machine at work and I&#8217;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 &#8211; BAM! &#8216;column such-and-such does not allow NULLs&#8217; blah, blah, blah&#8230;<\/p>\n<p>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&#8217;m getting back a NULL value.<\/p>\n<p>After digging around awhile my boss remembers something. You need to modify the pbodb11.5.ini file in the appropriate sections<\/p>\n<pre>[MS_SQLSERVER_SYNTAX]\nGetIdentity=&#039;Select SCOPE_IDENTITY()&#039;<\/pre>\n<p>This has been around since 2009, see <a href=\"http:\/\/groups.google.com\/group\/sybase.public.powerbuilder.general\/browse_thread\/thread\/bef22e189f1aea99\" target=\"_blank\" rel=\"noopener\">link<\/a>.<\/p>\n<p>and<\/p>\n<pre>[Microsoft SQL Server]\nServerCursor=&#039;No&#039;<\/pre>\n<p>From <a href=\"http:\/\/infocenter.sybase.com\/help\/index.jsp?topic=\/com.sybase.dc00359_0250\/html\/newfeatdw\/CEGJABBE.htm\" target=\"_blank\" rel=\"noopener\">Sybase web site<\/a>:<\/p>\n<p><em>ServerCursor database parameter<\/em><br \/>\n<em> 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:<\/em><\/p>\n<p><em>ServerCursor = &#8216;NO&#8217;<\/em><br \/>\n<em> The ServerCursor parameter can be used only in the PBODB initialization file.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I get a new machine at work and I&#8217;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&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[8,3],"tags":[46,12,45,15],"_links":{"self":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/723"}],"collection":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/comments?post=723"}],"version-history":[{"count":7,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/723\/revisions"}],"predecessor-version":[{"id":1931,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/723\/revisions\/1931"}],"wp:attachment":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/media?parent=723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/categories?post=723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/tags?post=723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}