Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Create Table with Sqlite
Create Table with Sqlite [message #12238] Sat, 20 October 2007 12:40 Go to next message
Alex is currently offline  Alex
Messages: 18
Registered: October 2007
Location: Germany
Promising Member
Hi,
I work for a few months with upp and now I have a problem with sqlite:

Sql sqlVer;
Sql sqlRaum;
Sql sqlNew;
	
sqlVer * Select(RAUMID).From(VERANST).Where(VID == id);
sqlRaum * Select(SEKTION,REIHE,PLATZ,PREISGR,XDISPL,YDISPL,COLDISPL).From(RAUMPLAN).Where(RNR == sqlVer[RAUMID]);
String TableName = Format("%08d",id);

String s = "CREATE TABLE V" + TableName; 
	s += " (ID integer primary key autoincrement , SEKTION integer, REIHE integer,";
	s += " PLATZ integer, PREISGR integer, XDISPL integer, YDISPL integer, COLDISPL integer)";

sqlNew.Execute(s);



Generates a error:

ERROR SQL logic error or missing database(0): CREATE TABLE V00000013 (ID integer primary key autoincrement , SEKTION integer, REIHE integer, PLATZ integer, PREISGR integer, XDISPL integer, YDISPL integer, COLDISPL integer)
ERROR database table is locked(0): Resetting statement: CREATE TABLE V00000013 (ID integer primary key autoincrement , SEKTION integer, REIHE integer, PLATZ integer, PREISGR integer, XDISPL integer, YDISPL integer, COLDISPL integer)



Can someone please tell me what is wrong here.

Thanks in advance,

Alex
Re: Create Table with Sqlite [message #12239 is a reply to message #12238] Sat, 20 October 2007 13:09 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Alex wrote on Sat, 20 October 2007 06:40

Hi,
I work for a few months with upp and now I have a problem with sqlite:

Sql sqlVer;
Sql sqlRaum;
Sql sqlNew;
	
sqlVer * Select(RAUMID).From(VERANST).Where(VID == id);
sqlRaum * Select(SEKTION,REIHE,PLATZ,PREISGR,XDISPL,YDISPL,COLDISPL).From(RAUMPLAN).Where(RNR == sqlVer[RAUMID]);
String TableName = Format("%08d",id);

String s = "CREATE TABLE V" + TableName; 
	s += " (ID integer primary key autoincrement , SEKTION integer, REIHE integer,";
	s += " PLATZ integer, PREISGR integer, XDISPL integer, YDISPL integer, COLDISPL integer)";

sqlNew.Execute(s);



Generates a error:

ERROR SQL logic error or missing database(0): CREATE TABLE V00000013 (ID integer primary key autoincrement , SEKTION integer, REIHE integer, PLATZ integer, PREISGR integer, XDISPL integer, YDISPL integer, COLDISPL integer)
ERROR database table is locked(0): Resetting statement: CREATE TABLE V00000013 (ID integer primary key autoincrement , SEKTION integer, REIHE integer, PLATZ integer, PREISGR integer, XDISPL integer, YDISPL integer, COLDISPL integer)



Can someone please tell me what is wrong here.

Thanks in advance,

Alex



Well, I guess this really is not an U++ problem, but some issue with your SQL and/or Sqlite. My first wild guess is that the table already exists in the database. Try DROP TABLE first to find out...

Mirek
Re: Create Table with Sqlite [message #12241 is a reply to message #12239] Sat, 20 October 2007 14:28 Go to previous messageGo to next message
Alex is currently offline  Alex
Messages: 18
Registered: October 2007
Location: Germany
Promising Member
luzr wrote on Sat, 20 October 2007 13:09


Well, I guess this really is not an U++ problem, but some issue with your SQL and/or Sqlite. My first wild guess is that the table already exists in the database. Try DROP TABLE first to find out...

Mirek


No, the table doesnt exist. The same command works successfully in Sqlite-Studio.
I will continue to experiment Crying or Very Sad

Alex
icon7.gif  Re: Create Table with Sqlite [message #12252 is a reply to message #12241] Sun, 21 October 2007 22:43 Go to previous messageGo to next message
Alex is currently offline  Alex
Messages: 18
Registered: October 2007
Location: Germany
Promising Member
Problem solved:

I have to delete all sql-connections (in this sample sqlVer and sqlRaum), and then does the "create table" command work.

Alex
Re: Create Table with Sqlite [message #12255 is a reply to message #12252] Mon, 22 October 2007 00:01 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Alex wrote on Sun, 21 October 2007 16:43

Problem solved:

I have to delete all sql-connections (in this sample sqlVer and sqlRaum), and then does the "create table" command work.

Alex


Thanks, looks like a good Sqlite tip Smile

Mirek
Re: Create Table with Sqlite [message #12964 is a reply to message #12255] Fri, 30 November 2007 18:05 Go to previous message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
luzr wrote on Sun, 21 October 2007 18:01

Alex wrote on Sun, 21 October 2007 16:43

Problem solved:

I have to delete all sql-connections (in this sample sqlVer and sqlRaum), and then does the "create table" command work.

Alex


Thanks, looks like a good Sqlite tip Smile

Mirek


Practice when Data Definition Language statements destroy all Data Manipulation Language statements is quite common. This situation should be handled by database API wrappers. Same as committing of all open transactions by DDL.

BTW. If recall correctly, there was an improvment to sqlite's API in order to fix similar situations.


Regards,
Novo
Previous Topic: Example code for CtrLib/Sqlite needed
Next Topic: How to use Clipboard in HomeBudget(SqLite3)?
Goto Forum:
  


Current Time: Sat Apr 20 10:34:40 CEST 2024

Total time taken to generate the page: 0.03372 seconds