Coding 'n stuff
Monthly Archives: March 2008
In NetCOBOL for .NET v3.1 you can get fast forward, read-only cursors provided you configure the ODBC settings in your configuration file accordingly. By default, all cursors will be read only. Unfortunately, many people use cursors for updating as well, and usually get this to work by changing the @SQL_CONCURRENCY option to something other than READ_ONLY. This option will affect all cursors in the application, and turn read only cursors into dynamic ones (which perform much slower than their read only counterparts).
You can get around this by using SQL Options in the NetCOBOL configuration section. Basically you create two options, one for read only cursors, and the other for updatable cursors. Then, set the @SQL_ODBC_CURSOR_DEFAULT and @SQL_ODBC_CURSOR_UPDATE settings to point to these two options so that NetCOBOL can pick the correct SQL Option depending on the cursor type. You are probably asking: How does it know what type the cursor is? The answer is that it looks for the FOR UPDATE clause in the cursor declaration. In order for this setup to work, you will need to change all of the cursor declarations for any cursor that is used for updating.
Here’s a sample of what your SQL settings might look like:
Here is a sample SQL cursor declaration for an updatable cursor:
If you are launching cscript on behalf of a user using a delegated token or by creating a token via LogonUser on a server that the user has never interactively logged on before, you will probably get an error like "Loading your settings failed. (Access is denied)."
This problem is caused by not having the Windows Scripting Host registry settings in the users HKCU registry hive. You can solve this for all users by adding the following keys:
HKEY_USERS\.DEFAULT\Software\Microsoft\Windows Scripting Host\Settings\
HKEY_USERS\.DEFAULT\Software\Microsoft\Windows Script Host\Settings\
You’ll want to make sure that the users also have read access to these keys as well.