Deks Posted December 1, 2011 Share Posted December 1, 2011 Hello, i have one little problem and can't pass it. Problem is i need to call new sql query inside another query. Am trying to make accordion which will put result of first query($sql) like title and result of second query($sql2) like list of current item. All time am getting error : Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt, SQL state S1000 in SQLExecDirect in ..... I know reasone is because i use query inside query so am trying to figure is there any way to bypass it or make it work. Example: $sql="EXECUTE _PROCEDURE1 '".$date."',''.$code."; $rs=odbc_exec($conn,$sql); if (!$rs){exit("Error in SQL");} while (odbc_fetch_row($rs)){ $id_number=odbc_result($rs,"ID"); $name=odbc_result($rs,"NAME"); echo $id_number.' - '.$name; $sql2="EXECUTE _PROCEDURE2 '".$id_number."',''.$name."; $name=odbc_exec($conn,$sql2); while(odbc_fetch_row($popust)){ $detail = odbc_result($sql2,"DETAILS"); $detail2 = odbc_result($sql2,"DETAILS2"); $detail3 = odbc_result($sql2,"DETAILS3"); echo $detail.' - '.$detail2.' - '.$detail3; } } I hope i explained it well. Thanks. Link to comment https://forums.phpfreaks.com/topic/252203-sql-query-error/ Share on other sites More sharing options...
trq Posted December 1, 2011 Share Posted December 1, 2011 i have one little problem and can't pass it. Problem is i need to call new sql query inside another query. That alone is a bad idea. See here for a solution: http://www.phpfreaks.com/tutorial/data-joins-unions Link to comment https://forums.phpfreaks.com/topic/252203-sql-query-error/#findComment-1292991 Share on other sites More sharing options...
Deks Posted December 2, 2011 Author Share Posted December 2, 2011 yea i know its bad idea, and link u gave me is ok..but problem is am calling 2 procedures. Also second procedure use result from first procedure. Any idea how to do it? thx. Link to comment https://forums.phpfreaks.com/topic/252203-sql-query-error/#findComment-1293435 Share on other sites More sharing options...
trq Posted December 2, 2011 Share Posted December 2, 2011 You can do it with a single query using a JOIN. Link to comment https://forums.phpfreaks.com/topic/252203-sql-query-error/#findComment-1293634 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.