SQLite Forum

Are Views just stored SQL Strings or something more?
Login
While a view cannot be parameterized, it is possible to fake it using a "magnet" virtual table; I have seen this suggested in the mailing list once, and I have also implemented it. The "magnet" virtual table merely returns a single row with the value it is constrained to have by the query (if the value isn't constrained, then it is an error). For example, then you can write:
```sql
create view a(b,c) as select value*value,value from magnet(value);
select b from a where c=5;
select b from a where c=6;
```
However, you cannot use table-valued-function syntax with views, since views don't have hidden columns (adding HIDDEN in the list of column names before AS is an error; HIDDEN and DEFAULT are the two things it might make sense to accept in that list (in addition to the column names), though).