Sqlite XE4 iOS

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
isysoftware
Posts: 44
Joined: Wed 14 Nov 2012 17:33

Sqlite XE4 iOS

Post by isysoftware » Sat 08 Jun 2013 16:49

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Sqlite XE4 iOS

Post by AlexP » Mon 10 Jun 2013 07:11

Hello,

We have already fixed the problem, this fix will be added to the next UniDAC version.

isysoftware
Posts: 44
Joined: Wed 14 Nov 2012 17:33

Re: Sqlite XE4 iOS

Post by isysoftware » Mon 10 Jun 2013 07:37

Hi Alex, thanks for your reply.
When do you think that the fix will be released?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Sqlite XE4 iOS

Post by AlexP » Mon 10 Jun 2013 07:56

Hello,

We plan to release a new version in the next month.

isysoftware
Posts: 44
Joined: Wed 14 Nov 2012 17:33

Re: Sqlite XE4 iOS

Post by isysoftware » Mon 10 Jun 2013 08:01

Next month???

We couldn't have a patch at this moment?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Sqlite XE4 iOS

Post by AlexP » Mon 10 Jun 2013 08:15

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.

isysoftware
Posts: 44
Joined: Wed 14 Nov 2012 17:33

Re: Sqlite XE4 iOS

Post by isysoftware » Tue 11 Jun 2013 09:00

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Sqlite XE4 iOS

Post by AlexP » Tue 25 Jun 2013 13:02

hello,

I sent you a fixed version on July 13

isysoftware
Posts: 44
Joined: Wed 14 Nov 2012 17:33

Re: Sqlite XE4 iOS

Post by isysoftware » Thu 25 Jul 2013 17:12

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Sqlite XE4 iOS

Post by AlexP » Fri 26 Jul 2013 08:29

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));

isysoftware
Posts: 44
Joined: Wed 14 Nov 2012 17:33

Re: Sqlite XE4 iOS [and now XE5 windows]

Post by isysoftware » Mon 07 Apr 2014 13:09

Hi Alex,
the same problem is now on XE5 whit SQLite in Windows.
For iOS I haven't problem, but whit windows yes.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Sqlite XE4 iOS

Post by AlexP » Mon 07 Apr 2014 14:19

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.

isysoftware
Posts: 44
Joined: Wed 14 Nov 2012 17:33

Re: Sqlite XE4 iOS

Post by isysoftware » Mon 07 Apr 2014 15:35

Yes, I mean this.
Ok, I can use isNull, and it works, but for iOS I haven't this problem.

Thanks,
Flavio

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Sqlite XE4 iOS

Post by AlexP » Tue 08 Apr 2014 11:58

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.

isysoftware
Posts: 44
Joined: Wed 14 Nov 2012 17:33

Re: Sqlite XE4 iOS

Post by isysoftware » Tue 08 Apr 2014 13:11

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;

Post Reply