Overview
Features
Download
Documentation
Community
Add-Ons & Services

Issue deleting records from SQLite table

Please post support and help requests here.

Issue deleting records from SQLite table

Postby rakesh » 08 Oct 2012, 03:54

Hello,

I am trying out the Data framework and have made some progress. I am able to create tables as well as insert into them. However my first test at deleting records is failing. My code is as follows:

Code: Select all
void PersistenceManagerImpl::deleteCollection( const string& name )
{
  Session ses = getSession();
  if ( ses.isConnected() ) // added if statement to see if the database missing error message was related to invalid session
  {
    ses << "delete from Collections where name = :name", use( name ), now;
    collections.erase( name );
  }
}


My unit test code catches an exception with the following displayText "SQL Statement invalid or database missing: delete from Collections where name = :name"

I do have foreign key constraints and cascade deletes set on the table. As per SQLite manual I execute a pragma statement as part of the PersistenceManager singleton initialisation process.

Code: Select all
ses << "PRAGMA foreign_keys = ON", now;


Any ideas on what the issue is? I tried a simple delete statement "delete from Collections" and I get the same error. Running the same command (both versions) from sqlite3 terminal session works as expected.

Thanks
Rakesh
rakesh
 
Posts: 78
Joined: 13 Apr 2011, 17:43
Location: Chicago

Re: Issue deleting records from SQLite table

Postby rakesh » 08 Oct 2012, 16:55

Definitely seems to be related to foreign key constraints. I re-ran my tests without foreign key constraints on my tables and everything went fine. Has anyone managed to enable foreign key constrains in SQLite when using Poco::Data?
rakesh
 
Posts: 78
Joined: 13 Apr 2011, 17:43
Location: Chicago


Return to Support

Who is online

Users browsing this forum: No registered users and 6 guests