Hi folks, I had another question.

The following statement seems to work just fine in the sqlite3 command
line client:

        create table sorter (key,val);
        [create an index on it, insert some stuff into it]
        create temp view sorter_sub1 as select * from sorter where key >= 2
and key < 8;

But the following line in java throws an SQLException:

        PreparedStatement prep = conn.prepareStatement(
                "create temp view "+newTable
                +" as select * from "+table
                +" where key >= ? and key < ?;");

Specifically: "java.sql.SQLException: parameters are not allowed in
views."

Something doesn't seem quite right here... perhaps the parser thinks
I'm passing parameters to the create temp view instead of the select
statement or something.  The error message comes from the SQLite C
code for creating views.  If I were to venture a guess, maybe the C
code is being passed stuff in pParse when it should've been getting it
through pSelect.

What's the right way to do this?  The answer is certainly not to
somehow parse the arguments myself and insert them into the strings
manually on a normal Statement, I can think of a lot of reasons why
that's a bad idea.  There's no way to create a select prepared
statement and then do something like "create temp view as <tie in
prepared statement here>", right?

I suppose otherwise, if this is just something that can't be done with
the jdbc driver, I can make a new table and new index and do a "insert
into select" thing (at least I know insert statements work with
parameters!).  But that seems a bit wasteful (of space and speed) and
seems like what views were made for.

-danny
--~--~---------~--~----~------------~-------~--~----~
Mailing List: http://groups.google.com/group/sqlitejdbc?hl=en
To unsubscribe, send email to [EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---

Reply via email to