> Hi all,
> I had the application using sqlite and executing the following sql statement:
> executeStmt: Error in executing the statment database TCPADDB is already in 
> use. Error St = 1 , stmt =   ATTACH DATABASE 
> \'/opt/phoenix/monitor/TCPFlowCurDayDB\'  as TCPADDB; insert into 
> tcpFlowTable select (strftime(\'%s\',date(startTime * 60,\'unixepoch\')))/60 
> , appId, remoteId, sum(ptFlowCountAgv) ,sum(proxyFlowCountAgv ), 
> sum(ptFlowCountDiff) , sum(proxyRequestCountDiff) , sum(proxyFlowCountDiff) , 
> sum(failedToProxyCountDiff ) from TCPADDB.tcpFlowTable  group by appId, 
> remoteId ; DETACH DATABASE TCPADDB ; 
>  
> The error message return back is the database(TCPADDB) is alreay in use but I 
> have checked the codes and didn't see any connection is opened for this 
> database so what is the problem here. Please give some hints where to look in 
> the codes to find this problem. I didn't see any connection is currently 
> opened for this database at the time the application executing above sql 
> statement. Any help is greatly appreciated.
> Thanks,
> JP

I don't think the issue is that you have opened a separate connection to 
this database (via sqlite3_open_v2()).  Instead, the message indicates 
that you have already ATTACH-ed the TCPADDB database into the existing 
connection.

A likely candidate is the SQL query you attached above (or one like it). 
  Your query has 3 statements in one: ATTACH, INSERT, and DETACH.  If 
the INSERT portion fails for any reason, the query may abort, and the 
DETACH won't run.  This causes problems for the next query, since you 
are attached when you don't expect to be.

I would suggest that you move the ATTACH / DETACH statements into 
separate queries so that you can ensure they are called at the 
appropriate times.

~Eric
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to