php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2117 odbc_exec and odbc_execute err out
Submitted: 1999-08-20 14:40 UTC Modified: 2001-02-10 15:33 UTC
From: mike at crt dot net Assigned: kara (profile)
Status: Closed Package: ODBC related
PHP Version: 3.0.11 OS: NT 4 Sp 4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mike at crt dot net
New email:
PHP Version: OS:

 

 [1999-08-20 14:40 UTC] mike at crt dot net
   I have a binary distribution of 3.0.11 which dies on a certain ODBC query.  None of the other bug reports I found have helped me alleviate this problem.  ODBC works fine on any basic query although it errors out on complex queries.  This query runs perfectly on 3.0RC3 but fails miseralbly on 3.0.6 and 3.0.11 which leads me to believe there is a Php problem.  I can also run this query directly on the server (MS SQL 6.5) or via Cold Fusion without any problems.
   My ODBC log tells me that it exits SQLFreeStmt fine, but returns an error from SQLExecute.  My MS ODBC drivers are at the current version (3.5)
   Basic code:
$conn = odbc_connect("<db>", "<username>", "<password>");  // returns positive connection id
$result = odbc_exec($conn, $select_stmt);  // errs out
      or
$conn = odbc_connect("<db>", "<username>", "<password>");  // returns positive connection id
$prepare_result = odbc_prepare($conn,$select_stmt);  // returns positive result id
$result = odbc_execute($prepare_result);  // errs out

Different values for $select_stmt and their corresponding results under 3.0.6 and 3.0.11:

1. Simple query
$select_stmt="SELECT coupons.cpn_org_code, coupons.cpn_effective_through, 
	coupons.cpn_url
	FROM Coupons
	WHERE Coupons.cpn_effective_start<=getDate() 
		AND Coupons.cpn_effective_through>=getDate()
		ORDER BY Coupons.cpn_org_code";
No error!
---
2. Medium query
$select_stmt="SELECT neworg.org_name,  
	neworg.org_url, neworg.org_addr_1, neworg.org_addr_2, neworg.org_addr_3, 
	neworg.org_city, neworg.org_state, neworg.org_zip, neworg.org_phone_1 
	FROM newtxt, neworg
	WHERE newtxt.txt_description LIKE '%test%' 
	ORDER BY newtxt.txt_sequence";
Error:
Warning: SQL error: [Microsoft][ODBC SQL Server Driver]Cursor type changed, SQL state 01S02 in SQLExecute in C:\public\phpdb.samsa.com\admin\maintorgs\dspcpnsch.php3 on line 72
---
3. Complex query
$select_stmt="SELECT coupons.cpn_org_code, coupons.cpn_effective_through, 
	coupons.cpn_url, newtxt.txt_description, neworg.org_name,  
	neworg.org_url, neworg.org_addr_1, neworg.org_addr_2, neworg.org_addr_3, 
	neworg.org_city, neworg.org_state, neworg.org_zip, neworg.org_phone_1 
	FROM (Coupons INNER JOIN newtxt ON (coupons.cpn_org_code = newtxt.txt_org_code) AND (Coupons.cpn_sequence = newtxt.txt_sequence))
	INNER JOIN neworg on coupons.cpn_org_code = neworg.org_code 
	WHERE (coupons.cpn_active_='Y' AND Coupons.cpn_effective_start<=getDate() 
	AND Coupons.cpn_effective_through>=getDate() AND newtxt.txt_type='CPN'  
	AND newtxt.txt_description LIKE '%test%') 
	ORDER BY Coupons.cpn_org_code, newtxt.txt_sequence";
Error:
Warning: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]WARNING - Fatal Error 602 occurred at Aug 20 1999 2:20PM. Please note the error and time, and contact your System Administrator., SQL state S1000 in SQLExecute in C:\public\phpdb.samsa.com\admin\maintorgs\dspcpnsch.php3 on line 65

   Thanks in advance,
   Mike Reed

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-08-27 16:58 UTC] mike at crt dot net
Added Aug. 27, 1999:
Further testing shows that the ORDER BY clause is causing 
the query to fail.  The query performs fine without this 
clause.
 [1999-11-28 11:52 UTC] kara at cvs dot php dot net
Does this also happen with odbc_do / odbc_exec?
 [2001-02-10 15:33 UTC] jimw@php.net
no feedback, closing.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 14:01:31 2024 UTC