* * *

Author Topic: Sqlite issues with views...  (Read 1732 times)

helio

  • New member
  • *
  • Posts: 9
Sqlite issues with views...
« on: November 28, 2016, 12:30:14 pm »
What is the correct way to create a view in sqlite, according to the sqlite manual I can use these two types below


Table =>  CREATE TABLE "test" ("column1" TEXT, "column2" TEXT, "column3" TEXT)

1 => CREATE view "test_view" (col1, col3) as select "column1", "column3" from "test"

2 => CREATE view "test_view" as select "column1" as col1, "column3" as col3 from "test"



What's wrong with sqldb? Error in 1 statement!!!

eny

  • Hero Member
  • *****
  • Posts: 1551
Re: Sqlite issues with views...
« Reply #1 on: November 28, 2016, 04:37:36 pm »
Maybe a semicolon after each line?
All posts based on: Win10 (Win64); Lazarus 1.4.2 'stable' (#49524 win32) unless specified otherwise...

helio

  • New member
  • *
  • Posts: 9
Re: Sqlite issues with views...
« Reply #2 on: November 28, 2016, 05:36:04 pm »
CREATE view "test_view" (col1, col3) as select "column1", "column3" from "test"


If I create the VIEW like this with above, I can not make select in any other table of the bank .... but the bank is not corrupted because I can access it with another tool;

vrull

  • Full Member
  • ***
  • Posts: 101
Re: Sqlite issues with views...
« Reply #3 on: November 28, 2016, 08:36:25 pm »
I agree, when I tried to create a view with syntax (1) I also got an error message - SQLite was not happy with column list. Maybe it is Lazarus-specific issue.

Syntax (2) works just fine. Stick to it.

About not able to open other tables - maybe you locked the database. Do you have closing transaction in your code?

helio

  • New member
  • *
  • Posts: 9
Re: Sqlite issues with views...
« Reply #4 on: November 29, 2016, 10:41:32 am »
No, no lock... the error is in reading the schema...

GAN

  • Jr. Member
  • **
  • Posts: 72
Re: Sqlite issues with views...
« Reply #5 on: February 16, 2017, 03:11:34 am »
What is the correct way to create a view in sqlite, according to the sqlite manual I can use these two types below


Table =>  CREATE TABLE "test" ("column1" TEXT, "column2" TEXT, "column3" TEXT)

1 => CREATE view "test_view" (col1, col3) as select "column1", "column3" from "test"

2 => CREATE view "test_view" as select "column1" as col1, "column3" as col3 from "test"


Must be:
1-
Code: Pascal  [Select]
  1. CREATE VIEW test_view AS SELECT column1, column2 FROM test;
  2.  

2-
Code: Pascal  [Select]
  1. CREATE VIEW test_view2 AS SELECT column1 AS col1, column3 AS col3 FROM test;
  2.  

Please check it and post results.
Lazarus 1.6 FPC 3.0.0 Linux Mint Mate 17.2 x86_64 GTK-2
Zeos 7.1.3 - Sqlite 3.8.2

Foro Lazarus en español http://forum.lazarus.freepascal.org/index.php/board,73.0.html

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus