Page 1 of 2
Sqlite XE4 iOS
Posted: Sat 08 Jun 2013 16:49
by isysoftware
Hi All.
I have this code for an application in Delphi XE4 for iOS with a Sqlite Database.
If I execute my app on Windows, it works.
Deployng it on a real iPAD, it don't work.
Code: Select all
function DeterminaID_Generico_a(aConnection: TUniConnection; aTable, aKey: string; aowner: TComponent):integer;
var aDs:TUniQuery; aNum:integer;
begin
aDs:=TUniQuery.Create(aowner);
with aDs do
begin
connection:=aConnection;
active:=False;
sql.Clear;
SQL.add('SELECT max('+aKey+') as mymax FROM '+aTable);
active:=True;
end;
if(aDs.RecordCount > 0) then
begin
if(aDs.FieldValues['mymax'] = null) then
result:=1
else
begin
aNum:=aDs.FieldByName('mymax').asinteger;
result:=aNum+1;
end;
end
else
result:=1;
end;
This code don't work: why? Can you help me?
Thanks
Re: Sqlite XE4 iOS
Posted: Mon 10 Jun 2013 07:11
by AlexP
Hello,
We have already fixed the problem, this fix will be added to the next UniDAC version.
Re: Sqlite XE4 iOS
Posted: Mon 10 Jun 2013 07:37
by isysoftware
Hi Alex, thanks for your reply.
When do you think that the fix will be released?
Re: Sqlite XE4 iOS
Posted: Mon 10 Jun 2013 07:56
by AlexP
Hello,
We plan to release a new version in the next month.
Re: Sqlite XE4 iOS
Posted: Mon 10 Jun 2013 08:01
by isysoftware
Next month???
We couldn't have a patch at this moment?
Re: Sqlite XE4 iOS
Posted: Mon 10 Jun 2013 08:15
by AlexP
Hello,
Please send us your license number and e-mail to alexp*devart*com in order for me to send you the fixed version of UniDAC.
Re: Sqlite XE4 iOS
Posted: Tue 11 Jun 2013 09:00
by isysoftware
Hi Alex,
yesterday I have sent you an E-Mail.
I have received a link to download Unidac: I have installed it, but I have the same problem. Maybe It isn'n the last version of Unidac whit fix
Re: Sqlite XE4 iOS
Posted: Tue 25 Jun 2013 13:02
by AlexP
hello,
I sent you a fixed version on July 13
Re: Sqlite XE4 iOS
Posted: Thu 25 Jul 2013 17:12
by isysoftware
Hi Alex,
Thanks for your reply: now problem is fixed and Max function works on ipad.
I have a question:
if a table is empty, Max Function Return ' " ' (double quote) else return a value (integer ).
In my code I check if Max's returnerd value is NULL or not.
There is a problem if I change my code to check if returned value is = '': if table is empty, there isn't any problem; but if table has record, in IF statement there will be an AV on converting string '' in integer.
Have you any ideas?
Thanks
Re: Sqlite XE4 iOS
Posted: Fri 26 Jul 2013 08:29
by AlexP
Hello,
To check the field for a Null value, you can use the IsNull property of this field, for example:
LiteConnection1.ExecSQL('CREATE TABLE TEST(ID INTEGER)');
LiteQuery1.SQL.Text := 'SELECT MAX(ID) as ID FROM TEST';
LiteQuery1.Open;
if not LiteQuery1.Fields[0].IsNull then
ShowMessage(IntToStr(LiteQuery1.Fields[0].AsInteger));
Re: Sqlite XE4 iOS [and now XE5 windows]
Posted: Mon 07 Apr 2014 13:09
by isysoftware
Hi Alex,
the same problem is now on XE5 whit SQLite in Windows.
For iOS I haven't problem, but whit windows yes.
Re: Sqlite XE4 iOS
Posted: Mon 07 Apr 2014 14:19
by AlexP
If you mean, that an empty string is returned when DataSet is empty, when using aggregating functions, then this behavior is similar for every platform, and you should use the Fields.isnull method to check data existence. There is no more errors when executing your code.
Re: Sqlite XE4 iOS
Posted: Mon 07 Apr 2014 15:35
by isysoftware
Yes, I mean this.
Ok, I can use isNull, and it works, but for iOS I haven't this problem.
Thanks,
Flavio
Re: Sqlite XE4 iOS
Posted: Tue 08 Apr 2014 11:58
by AlexP
On both operation systems (win32 and iOS), the error occurs at the line "aDs.FieldByName('mymax').asinteger" on an attempt to map an empty string to Integer. If you have another error, please provide the error message text and the line where it occurs.
Re: Sqlite XE4 iOS
Posted: Tue 08 Apr 2014 13:11
by isysoftware
This is the code that I'm using: in iOS it works and in Windows no.
Code: Select all
aDs:=TUniQuery.Create(aOwner);
with aDs do
begin
connection:=aConnection;
active:=False;
SQL.add('Select Max('+aKey+') as Massimo From '+LowerCase(aTable));
active:=True;
end;
if((aDs.RecordCount>0)) then
begin
if(aDs.FieldValues['Massimo'] = null) then
result:=1
else
begin
aNum:=aDs.FieldValues['Massimo'];
result:=aNum+1;
end;
end
else
result:=1;