On 25/02/2009 11:34 AM, P Kishor wrote:
> On Tue, Feb 24, 2009 at 6:12 PM, John Machin <sjmac...@lexicon.net> wrote:
>> On 25/02/2009 10:30 AM, P Kishor wrote:
>>> On Tue, Feb 24, 2009 at 5:19 PM, Leo Freitag <leofrei...@netcologne.de>
>>> wrote:
>>>> Hallo,
>>>>
>>>> I'm trying to insert the highest value of tblName into tblZO.
>>>>
>>>> There fore I followed the hints in this article ...
>>>>
>>>> http://www.nabble.com/How-to-use-the-ROWID-of-the-last-inserted-row-for-FK-insert-into-other-tables--td19085514.html#a19085514
>>>>
>>>> ... but I got a error (see below)
>>>>
>>>> SQLite version 3.3.13
>>>> Enter ".help" for instructions
>>>> sqlite> create 'tblName' ('id' integer primary key, 'text' text);
>>>> SQL error: near "'tblName'": syntax error
>>>> sqlite> create table 'tblName' ('id' integer primary key, 'text' text);
>>>> sqlite> insert into 'tblName' Values (NULL, 'one');
>>>> sqlite> insert into 'tblName' Values (NULL, 'two');
>>>> sqlite> insert into 'tblName' Values (NULL, 'three');
>>>> sqlite> insert into 'tblName' Values (NULL, 'four');
>>>> sqlite> insert into 'tblName' Values (NULL, 'five');
>>>> sqlite> create table 'tblRefMaxName' ('ref' integer, 'nn' text);
>>>> sqlite> insert into 'tblRefMaxName' Values (select max(id) from tblName,
>>>> 'eins')
>>> select max(id) from tblName, 'eins' is not a valid select statement.
>> That is not the problem. Consider this:
> 
> actually it is the problem. I wasn't clear in my explanation so that
> is my fault.
> 
> the following is a valid statement: SELECT Max(id) FROM tbl
> 
> but the following is problematic: SELECT Max(id) FROM tbl, 'eins'
> 
> because the SQL parser is looking for a table called 'eins'

I don't believe it is looking for a table at all. After parsing "VALUES" 
and  "(", the next construct expected is an "expr". The next available 
token is the keyword "SELECT". Look through the railroad syntax diagram 
for "expr". None of the possibilities can start with a keyword "SELECT". 
A sensibly written parser can stop right there, and emit an error 
message, something like <SQL error: near "select": syntax error> ... it 
is not going to try mucking about parsing a full select statement when 
one can not legally exist at that position.

I can't imagine ever having to suspect that any part of SQLite is not 
sensibly written :-)

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to