Re: RE: ODBC cursor fix

From: Date: Tue, 10 Nov 1998 00:31:07 +0000
Subject: Re: RE: ODBC cursor fix
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-2308@lists.php.net to get a copy of this message
On 2 Nov 98, at 16:44, Dave Walton wrote: > On 17 Sep 98, at 9:06, Shane Caraveo wrote: > > > I've looked at this stuff further now, and realize there isn't any way to do > > this other than extra options to the connect function. > > > > Email me the stuff, I'll commit it to the cvs tree. > > Shane, > > Here's the diff (finally). This works for us on NT with MS-SQL, > though it could potentially cause problems with other configurations > if sqlext.h doesn't define the necessary constants. It looks like Shane isn't going to be able to take care of this for a while. Could someone else please commit this diff? Here's the background: We are using PHP3 on NT4 connecting to MS-SQL via ODBC. A few of the complex stored procedures we use cause odbc_exec() to fail with an ODBC error reporting "Cannot open a cursor on a stored procedure that has anything other than a single select statement in it". Investigation showed that there are two types of cursors: ODBC cursors and driver cursors. The default is a driver cursor, but if we use an ODBC cursor instead, the stored procedures run without error. The bad news is that the cursor type for a connection can only be set before the connection is established, which means that support for selection of cursor type can only be added as an option to odbc_connect(). The attached diff (which is against v1.87 of unified_odbc.c) implements an optional fourth parameter to odbc_connect() that specifies the cursor type. It also defines the following constants for use in that parameter: SQL_CUR_USE_IF_NEEDED SQL_CUR_USE_ODBC SQL_CUR_USE_DRIVER SQL_CUR_DEFAULT In addition, the option that is used for a connection is added to the hashed details for that connection, so that a connection ID will only be reused if the same option is given. The only problem that may (or may not) exist with this patch is that the above four constants must be defined in sqlext.h. Since we don't have access to the include files for all the database servers that use unified_odbc.c, I can't be certain that those defines exist in all of them. That should be checked by whomever has the proper files. When to use: Most people will not need to use the new option. However, anyone encountering an ODBC error similar to the one above can try using different connect options to correct the problem. Dave ---------------------------------------------------------------------- Dave Walton Webmaster, Postmaster Nordic Entertainment Worldwide walton@nordicdms.com http://www.nordicdms.com ----------------------------------------------------------------------

« previous php.dev (#2308) next »