Recent

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

helio

  • New Member
  • *
  • Posts: 29
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: 1634
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 2.0.10 'stable' (x64) unless specified otherwise...

helio

  • New Member
  • *
  • Posts: 29
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: 118
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: 29
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

  • Sr. Member
  • ****
  • Posts: 370
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 2.0.8 FPC 3.0.4 Linux Mint Mate 19.3
Zeos 7̶.̶2̶.̶6̶ 7.1.3a-stable - Sqlite 3.32.3 - LazReport

 

TinyPortal © 2005-2018