Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Sqllite function Max() and alias not work in XE8,10


This question is answered.


Permlink Replies: 4 - Last Post: Dec 30, 2015 6:14 PM Last Post By: Andrey HelleR Threads: [ Previous | Next ]
Andrey HelleR

Posts: 5
Registered: 10/19/13
Sqllite function Max() and alias not work in XE8,10  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 25, 2015 3:19 PM
Hello.
In XE5 this code, it works.
When transfer to XE8,XE10 -> error.

// SQL_READ: TSQLQuery;
try
dm1.SQL_READ.Close;
dm1.SQL_READ.SQL.Clear;
dm1.SQL_READ.SQL.Add('SELECT Max('+table_name+'_ID) AS c1 FROM '+table_name);
dm1.SQL_READ.Open;

Result := dm1.SQL_READ.FieldByName('c1').AsInteger;
except
on E: Exception do
Form1.Log_m.Lines.Add('Error Max_READ() E: '+E.Message);

// Error text E:SQL_READ:Field 'c1' not found
end;

Thanks for the advice.
quinn wildman

Posts: 856
Registered: 12/2/99
Re: Sqllite function Max() and alias not work in XE8,10  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 28, 2015 8:10 AM   in response to: Andrey HelleR in response to: Andrey HelleR
Your error is being returned by the server. Try running the statement is
something outside of Rad Studio and I expect you'll get the same error.

Andrey HelleR wrote:
Hello.
In XE5 this code, it works.
When transfer to XE8,XE10 -> error.

// SQL_READ: TSQLQuery;
try
dm1.SQL_READ.Close;
dm1.SQL_READ.SQL.Clear;
dm1.SQL_READ.SQL.Add('SELECT Max('+table_name+'_ID) AS c1 FROM '+table_name);
dm1.SQL_READ.Open;

Result := dm1.SQL_READ.FieldByName('c1').AsInteger;
except
on E: Exception do
Form1.Log_m.Lines.Add('Error Max_READ() E: '+E.Message);

// Error text E:SQL_READ:Field 'c1' not found
end;

Thanks for the advice.
Andrey HelleR

Posts: 5
Registered: 10/19/13
Re: Sqllite function Max() and alias not work in XE8,10  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 29, 2015 2:05 AM   in response to: quinn wildman in response to: quinn wildman
quinn wildman wrote:
Your error is being returned by the server. Try running the statement is
something outside of Rad Studio and I expect you'll get the same error.

Andrey HelleR wrote:
Hello.
In XE5 this code, it works.
When transfer to XE8,XE10 -> error.

// SQL_READ: TSQLQuery;
try
dm1.SQL_READ.Close;
dm1.SQL_READ.SQL.Clear;
dm1.SQL_READ.SQL.Add('SELECT Max('+table_name+'_ID) AS c1 FROM '+table_name);
dm1.SQL_READ.Open;

Result := dm1.SQL_READ.FieldByName('c1').AsInteger;
except
on E: Exception do
Form1.Log_m.Lines.Add('Error Max_READ() E: '+E.Message);

// Error text E:SQL_READ:Field 'c1' not found
end;

Thanks for the advice.

Thank you for your reply.
This code works for Rad Studio XE5, this method access the values of the functions Max, Min, Count, etc. I used to always.
The query is executed without error, the error in conversion to the alias.
This is the same method I use and it works with OS Win CE 5.0 in a development environment, Lazarus + sqlite.
Please note, the query runs without error, the only exception getting when trying access the alias.
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: Sqllite function Max() and alias not work in XE8,10
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 29, 2015 10:25 AM   in response to: Andrey HelleR in response to: Andrey HelleR
Andrey HelleR wrote:

quinn wildman wrote:
Your error is being returned by the server. Try running the
statement is something outside of Rad Studio and I expect you'll
get the same error.

Andrey HelleR wrote:
Hello.
In XE5 this code, it works.
When transfer to XE8,XE10 -> error.

// SQL_READ: TSQLQuery;
try
dm1.SQL_READ.Close;
dm1.SQL_READ.SQL.Clear;
dm1.SQL_READ.SQL.Add('SELECT Max('+table_name+'_ID) AS c1 FROM
'+table_name); dm1.SQL_READ.Open;

Result := dm1.SQL_READ.FieldByName('c1').AsInteger;
except
on E: Exception do
Form1.Log_m.Lines.Add('Error Max_READ() E: '+E.Message);

// Error text E:SQL_READ:Field 'c1' not found
end;

Thanks for the advice.

Thank you for your reply.
This code works for Rad Studio XE5, this method access the values
of the functions Max, Min, Count, etc. I used to always. The query
is executed without error, the error in conversion to the alias.
This is the same method I use and it works with OS Win CE 5.0 in a
development environment, Lazarus + sqlite. Please note, the query
runs without error, the only exception getting when trying access the
alias.

I never used Sqllite. You can always try to check out how the query
receives the data from the driver by using showmessage for example:

ShowMessage(FDQuery1.fields[0].FieldName)


(Maybe you will have to remove the persistant field.)
Andrey HelleR

Posts: 5
Registered: 10/19/13
Re: Sqllite function Max() and alias not work in XE8,10  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 30, 2015 6:14 PM   in response to: Lajos Juhasz in response to: Lajos Juhasz
Lajos Juhasz wrote:
Andrey HelleR wrote:

quinn wildman wrote:
Your error is being returned by the server. Try running the
statement is something outside of Rad Studio and I expect you'll
get the same error.

Andrey HelleR wrote:
Hello.
In XE5 this code, it works.
When transfer to XE8,XE10 -> error.

// SQL_READ: TSQLQuery;
try
dm1.SQL_READ.Close;
dm1.SQL_READ.SQL.Clear;
dm1.SQL_READ.SQL.Add('SELECT Max('+table_name+'_ID) AS c1 FROM
'+table_name); dm1.SQL_READ.Open;

Result := dm1.SQL_READ.FieldByName('c1').AsInteger;
except
on E: Exception do
Form1.Log_m.Lines.Add('Error Max_READ() E: '+E.Message);

// Error text E:SQL_READ:Field 'c1' not found
end;

Thanks for the advice.

Thank you for your reply.
This code works for Rad Studio XE5, this method access the values
of the functions Max, Min, Count, etc. I used to always. The query
is executed without error, the error in conversion to the alias.
This is the same method I use and it works with OS Win CE 5.0 in a
development environment, Lazarus + sqlite. Please note, the query
runs without error, the only exception getting when trying access the
alias.

I never used Sqllite. You can always try to check out how the query
receives the data from the driver by using showmessage for example:

ShowMessage(FDQuery1.fields[0].FieldName)


(Maybe you will have to remove the persistant field.)

Thank you.
I Use now:
result := dm1.SQL_READ.fields[0].Value;
//dm1.SQL_READ.fields[0].FieldName='Column0'

Edited by: Andrey HelleR on Dec 30, 2015 6:14 PM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02