Home » U++ Library support » U++ SQL » Create Table with Sqlite
Create Table with Sqlite [message #12238] |
Sat, 20 October 2007 12:40 |
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 |
|
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 #12964 is a reply to message #12255] |
Fri, 30 November 2007 18:05 |
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
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
|
|
|
Goto Forum:
Current Time: Wed Apr 24 00:56:50 CEST 2024
Total time taken to generate the page: 0.01687 seconds
|