Skip navigation
Jan S.
Currently Being Moderated

SQLite - select * from view

Feb 24, 2010 7:22 AM

Hello All,

 

I'm completely new to this forum. I've got some pretty big tables and have created views to hold some predefined data in them.

 

Now sqlite application I've used (Lita, SQLiteAdmin) does not see these views. Only from Firefox SQLiteManager add-on or the command line,  I can do a select * from my_view;

 

Now when I try to query my view from Air, I receive the error #3115 table : my_view does not exist? Is there a litmitation in Air to be able to query ONLY tables?

 

Thanks

 

Jan

 
Replies
  • Currently Being Moderated
    Feb 24, 2010 4:12 PM   in reply to Jan S.

    There is no limitation against getting at view data using a select.  Here is an overly simple example using a synchronous connection:

     

    var conn:SQLConnection = new SQLConnection();

    conn.open(File.applicationStorageDirectory.resolvePath("test.db"));

    var sql:SQLStatement = new SQLStatement();

    sql.sqlConnection = conn;

    sql.text = "CREATE TABLE IF NOT EXISTS employees (id Integer, name String);";

    sql.execute();

     

     

    sql.text = "INSERT INTO employees VALUES (1, 'Sam');";

    sql.execute();

     

     

    sql.text = "INSERT INTO employees VALUES (2, 'Bob');";

    sql.execute();

     

     

    sql.text = "CREATE VIEW IF NOT EXISTS emp_view AS SELECT name FROM employees WHERE name LIKE 'B%';";

    sql.execute();

     

     

    sql.text = "SELECT * FROM emp_view;";

    sql.execute();

    trace(ObjectUtil.toString(sql.getResult().data));

    Which outputs:
    (Array)#0
      [0] (Object)#1
        name = "Bob"

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points